Important: Please read the Qt Code of Conduct -

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 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!

  • Lifetime Qt Champion

    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,
    can be used.
    The DocumentsLocation or AppDataLocation could be a good location. ( depending on platform )

  • Thanks a lot! This is exactly what I was looking for, you have been very helpful :D

Log in to reply