PDA

View Full Version : Two database connections with different drivers at the same time?



goofacz
8th January 2012, 23:47
Hello!
I try to establish two database connections, one with PostgreSQL and second with SQLite. I start with code:

QSqlDatabase mainDatabase = QSqlDatabase::addDatabase("QPSQL", "MainDatabase");
QSqlDatabase mapDatabase = QSqlDatabase::addDatabase("QSQLITE", "MapDatabase");
then I setup and test connection with PostgreSQL – everything its fine so far. When I try to open SQLite databse with code:

mapDatabase.setDatabaseName("db_name");
if (!this->mapTilesDatabase.open())
{
// error handling
}
I recieve error: Driver not loaded.
Is it possible to use two different database divers simultaneously at all?

ChrisW67
9th January 2012, 01:23
Is it possible to use two different database divers simultaneously at all?
Yes. I have done so with ODBC and Sqlite. I am sure others have done your particular combination.

I recieve error: Driver not loaded.
Have you deployed the Sqlite plugin with your application?
Is it showing in the output of QSqlDatabase::drivers()?