Shipping SQLite database with application
-
Hello everyone, I have an application that uses an SQLite database and I am trying to properly integrate it with the application deployment.
The first thing I thought was to put the db file in the resource system, but that won't work as the file will be read-only, and I suspect it would be overwritten when updating the application.
While looking online I saw this thread https://forum.qt.io/topic/14714/adding-db-to-resources/2 where the advice is to put the db in the resource system and copy it somewhere else when the application starts [avoids read-only issue] only if it doesn't exist [avoids overwriting], then modify this new copy of the database.
Is this the correct way to go?
If so, how do I chose a valid path to copy the file to?
If not, how do I correctly deploy the database alongside the application?Thanks for any help!
-
Hi
Adding a DB to res file and save it to writable location on first run works very well with small databases.
To choose a valid path to copy the db to,
http://doc.qt.io/qt-5/qstandardpaths.html
can be used.
The DocumentsLocation or AppDataLocation could be a good location. ( depending on platform )