I have code that works:
QSqlDatabase db;
QSqlQuery query;
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(directory + QDir::separator() + "db.sqlite3");
db.open();
query.exec("create table mytable (id integer)");
But, if I try to name the added database by changing line 3 to:
db = QSqlDatabase::addDatabase("QSQLITE", "db");
I get a "Driver not loaded Driver not loaded" error. I've tried editing the SQL statement to all of the following, but nothing seems to work.
query.exec("create table db.mytable (id integer)");
query.exec("create table `db`.mytable (id integer)");
query.exec("create table 'db'.mytable (id integer)");
How do I query the specific database within the connection? I can find lots of examples for the default database, but nothing for named databases.