[Qt-interest] Runtime configuration of database drivers

Robert Hairgrove evorgriahr at hispeed.ch
Tue Dec 30 18:46:03 CET 2008


(opensource Qt-4.4.3)

Two questions:

(1) When a stand-alone application is running on a client's PC, how can 
the application "know" which databases are already installed? I have 
configured my compilation for as many databases as are allowed by the 
opensource version. These are MySQL, ODBC, PostgreSQL and SQLite.

The only one of these guaranteed to work on any machine is SQLite 
because it is compiled into Qt itself. All the others rely on shared 
libraries which might or might not be there. However, if someone wants 
to use PostgreSQL, for example, it is available.

Do we just try to connect at runtime and catch the error? Try to load 
the required libraries and see if they fail? Or is it better to provide 
support for the drivers as plugins?

(2) The QSqlDatabase::drivers() function returns some drivers twice, but 
with numbers, i.e.: QPSQL7 and QPSQL - QODBC and QODBC3 - etc. Is this 
for Qt3 support? The documentation seems a little lacking in this respect.

Thanks!



More information about the Qt-interest-old mailing list