PyQt + PygreSQL

N

Neil Zanella

Hello,

I am using the following with python:

The PyQt python bindings:

http://www.riverbankcomputing.co.uk/pyqt/

based on the Qt GUI Application Framework:

http://www.trolletch.com/

as well as the PyGreSQL python bindings:

http://www.pygresql.org/

based on the PostgreSQL database server:

http://www.postgresql.org/

I have the following question. When I instantiate QDataTable with C++
I must ensure that a database connection is open, and then have no
problems, otherwise I will get popup widgets with errors.

How can I properly set the default database connection and have
QDataTable find it using the combination of Python + PyQt + PyGreSQL?

Thanks,

Neil
 
G

Grzegorz Dostatni

I don't know how to set it up using pygresql, but you can do it using
qtsql module. Just make sure that qt was compiled with the postgresql
support.

If you need to use pygresql for some reason, you could always try to have
multiple connections to the database from you code (one through qtsql
module, another through qtsql). That will probably get very ugly very
quickly.

Greg
 
N

Neil Zanella

Grzegorz Dostatni said:
I don't know how to set it up using pygresql, but you can do it using
qtsql module. Just make sure that qt was compiled with the postgresql
support.

Thanks, I should have used the Python equivalent of QSqlDatabase::addDatabase()
to connect to PostgreSQL instead of using PyGreSQL. That way QDataTable can
find and use the database connection handle it knows about. After all, PyQt
knows nothing about PyGreSQL: as you just pointed out the two packages are
completely unrelated and independent of each other.
If you need to use pygresql for some reason, you could always try to have
multiple connections to the database from you code (one through qtsql
module, another through qtsql).

Exactly, but actually now that you pointed this out to me I don't think
I will need PyGreSQL since I'm already using the Qt database module.

Thanks,

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ANN: PyQt v5.2 Released 0
ANN: PyQt v5.3 Released 0
PyGreSQL 4.1 released 3
ANN: PyQt v4.8.1 Released 11
PyGresql 4.1.1 for python2.7 0
PyQt v4.7 Released 0
ANN: PyQt v4.6 Released 0
Release of PyGreSQL 4.0 0

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top