QSqlDatabase: QPSQL driver not loaded

Rich Shepard rshepard at appl-ecosys.com
Thu May 20 18:18:46 BST 2021

Running PyQt5-5.13.2 on Slackware64-14.2 with Postgresql-12.2 and
Python3-3.7.2. Also installed are /usr/lib/qt/include/QtSql/QPSQLDriver,
/usr/lib64/qt/include/QtSql/QPSQLDriver, and 

Developing my first PyQt5/SQL database application and working on a simple
module (to add a new activity type to the database table) I get these

$ python activitytype.py 
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE

The database connection code is:
 	# Set up database connection
         self.db = qts.QSqlDatabase.addDatabase('QPSQL')
         if not self.db.open():
             error = self.db.lastError().text()
                 None, 'DB Connection Error',
                 'Could not open database file: '

The build scripts for Qt5 and python3-PyQt4 have no configuration option for
database drivers.

The web page <https://doc.qt.io/qtforpython/overviews/sql-driver.html>
describes building on Windows, not linux.

1. How do I learn what SQL drivers are installed (other than QSQLITE)?

2. How do I make the QPSQLDriver available for use?



More information about the PyQt mailing list