Wednesday 29 May 2019

qgis - How to connect a PyQGIS plugin with Postgres?


I have some questions for you:


I created a python-plugin in QGIS,


then I created a Qt gui fom my plugin


and at last I created a Postgres DB


now I need to make a connection between Qt-gui and Postgres-DB


I wrote this


 from PyQt4.QtSql import *
db = QSqlDatabase.addDatabase("QPSQL");
db.setHostName("localhost");

db.setDatabaseName("siti");
db.setUserName("postgres");
db.setPassword("bina");
bool ok = db.open();

but it doesn't works, I can't understand what I do wrong...


I wish someone could help me...


thank you for all! lisa




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...