PyQt Digest, Vol 191, Issue 9

Sibylle Koczian nulla.epistola at web.de
Wed Jun 10 18:55:10 BST 2020


Am 10.06.2020 um 14:34 schrieb Nenad Lamza:
> Thanks Barry (and also Dennis) to your answers.
> 
> So, I have a choice:
> 
> 1. Use standard PyQt MVC, QSqlDatabase, QSqlQuery, QSqlQueryModel, 
> QSqlQueryModel, QTableView,..., but without ORM like SqlAlchemy, and 
> potentially have problems with PostgreSQL drivers
> 
> 2. Use other PostgreSQL drivers like psycopg2 and don't use PyQt MVC and 
> Sql classes and use ORM like SqlAlchemy with business logic and objects. 
> Isn't the whole point of (Py)Qt MVC to use all those classes I 
> mentioned? I can't imagine in that case (without PyQt Sql classes and 
> using SqlAlchemy) how would I present data to the user in eg. QTableView 
> or some other GUI table on screen? Building my own MVC (it takes years)?
> 
You can use the Qt Model-View classes, just without QtSql. Instead you 
could create your own Model class, subclassed from QAbstractItemModel or 
use a QStandardItemModel (or subclass that). And put your data, got via 
SQLAlchemy or directly from psycopg2, into that model. QTableView and 
QDataWidgetMapper can use that just as well as the QSql...Model classes.

HTH
Sibylle




More information about the PyQt mailing list