[PyQt] [PYQT5]display sqlite data in Qtableview Python
maziar.parsijani at gmail.com
Tue Jul 24 16:43:52 BST 2018
Well I am ok with those drivers I have problem with creating qsqltableview rows and columns and their codes like qtable widget which I can easyly do it but the problem is its low speed.
Sent from my iPhone
> On Mordad 2, 1397 AP, at 8:08 PM, J Barchan <jnbarchan at gmail.com> wrote:
>> On 24 July 2018 at 16:24, Maziar Parsijani <maziar.parsijani at gmail.com> wrote:
>> Obviously I have a problem with creation of qsqltableview not to put just my data base.
>> Here you can see that I can read my database :
>>> import sqlite3
>>> conn = sqlite3.connect(' sqlite path to file.db ')
>>> conn_cursor = conn.cursor()
>>> conn.text_factory = str
>>> res = conn.execute("SELECT text FROM table WHERE condition='?';")
>>> for text in res:
>>> print (text)
>> I need a help to put these data which is text in qsqltable view and the example have just created a db with its own data that I don't understand anything of it.
>>> On Tue, Jul 24, 2018 at 4:10 PM, Florian Bruhin <me at the-compiler.org> wrote:
>>> On Tue, Jul 24, 2018 at 01:54:13PM +0430, Maziar Parsijani wrote:
>>> > PYQT5 examples for sqlite and QSqlTableModel are not for reading sqlite
>>> > database and show them in QSqlTableModel.
>>> > I want to read my database rows and columns and show them in
>>> > QSqlTableModel.Are there any good examples for such thing ?
>>> The examples just use an in-memory database
>>> ("db.setDatabaseName(':memory:')" in connection.py). If you instead pass
>>> a filename to a sqlite database, it'll read that database.
>>> https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
>>> GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
>>> I love long mails! | https://email.is-not-s.ms/
>> PyQt mailing list PyQt at riverbankcomputing.com
> To start out from: you are using a dedicated Python import sqlite3 module.
> Unless you have a good reason (lots of existing code) which makes you want to stick with that, I would suggest instead you consider changing over to using the Qt MySQL database drivers (includes support for SQLite) & classes.
> That will allow you to use classes like QSqlTableModel easily, which in turn interface with QTableView naturally, and there are plenty of examples of that.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt