[SOLVED] Two database connections with different drivers at the same time?
-
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?
-
Welcome to DevNet!
Using different database drivers works without problems. Is the sqlite driver really available? What the output of
@
qDebug() << QSqlDatabase::drivers();
@I'm not sure if that's of importance, but in your second snippet you set the database name on mapDatabase but try to open mapTilesDatabase.