Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make an SQLITE database programatically in Qt?

Tags:

sqlite

qt

qt4

I am making a contact book application in Qt. I want my application to automatically create an QSQLITE database when it first runs and then access this database in future? Is there a way to do this?

like image 862
W.K.S Avatar asked Dec 29 '25 20:12

W.K.S


1 Answers

Ya you can create sqlite database at its first run and can make it progressive. Just do it in the constructor of your App and check for the existence of db before cerating it, else don't create. You can access database in subsequent runs of your same App or different App.

Use db.setDatabaseName("databasename.db"); instead of db.setDatabaseName(":memory:");, now your database will be persistent.

like image 117
ScarCode Avatar answered Dec 31 '25 19:12

ScarCode