· 8 years ago · Aug 30, 2018, 09:06 AM
1QT SQLite not working in Embedded device
2QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
3 db.setDatabaseName("songs.db");
4 if (!db.open()) {
5 QMessageBox::critical(0, qApp->tr("Cannot open database"),
6 qApp->tr("Unable to establish a database connection.n"
7 "This example needs SQLite support. Please read "
8 "the Qt SQL driver documentation for information how "
9 "to build it.nn"
10 "Click Cancel to exit."), QMessageBox::Cancel);
11 //return false;
12
13debugLog("#fileListThread::run()-> Unable to establish a database connection.."<<db.lastError(););
14 }
15else
16{
17 debugLog("#fileListThread::run()-> opened songs.db successfully..");
18}
19
20QSqlQuery query;
21
22
23bool queryStatus = query.exec("create table songsList (id int primary key, "
24 "Song varchar(20), Artist varchar(20),Producer varchar(20))");
25
26if(queryStatus)
27{
28 debugLog("#fileListThread::run()-> created table in songs DB successfully..");
29}
30else
31{
32 debugLog("#fileListThread::run()-> failed to create table in songs DB.."<<query.lastError(););
33}
34
35CREATE TABLE IF NOT EXISTS songsList
36
37create table songsList