Hello!
I'm trying to read from SQLite database. I've wrote simple function:
void MainWindow::odczytajBazeSQL()
{
bdb.setDatabaseName("/test.db");
bdb.open();
queryModel->setQuery("SELECT * FROM t1", bdb);
ui->tableView->setModel(queryModel);
}
void MainWindow::odczytajBazeSQL()
{
QSqlDatabase::addDatabase("QSQLITE");
QSqlDatabase bdb;
bdb.setDatabaseName("/test.db");
bdb.open();
QSqlQueryModel *queryModel = new QSqlQueryModel;
queryModel->setQuery("SELECT * FROM t1", bdb);
ui->tableView->setModel(queryModel);
}
To copy to clipboard, switch view to plain text mode
test.db is a simple database with one table t1. When I'm trying to read with code above I get error:
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:
QSqlQuery::exec: database not open
To copy to clipboard, switch view to plain text mode
Normally I'm using sqlite3 to create and use databases. What should I do to make it work?
thanks in advance
best regards
Tomasz
Bookmarks