Nominate our 2022 Qt Champions!

Install sqlite database file together with Application

  • Hi,

    I have SQLite Database file "MyDb.db" in my project folder I would like to deploy this file together with application
    to the build folder. My question is what is right approach to do that and its same for Mobile targets and Desktop targets.

    Thank you, for any help

  • Lifetime Qt Champion


    Does this database contain any data ? If not, then you can avoid include it and generate it from your application otherwise you can embed it with qrc and on the first application run (or if the database is missing) copy it to an appropriate folder using QStandardPaths to retrieve the right folder for that.

    Hope it helps

  • SGaist thanks for reply. Sqlite will be contain data, I was also thinking about embedding with qrc but I'm not sure if this ideal solution on mobile devices if the database will be big and then I will be almost doubling size of application.

    Let's put the question different way.
    I'm working on something as Dictionary app where I need to be able to modify data of the Dictionary. I'm wondering what will be the ideal design for that. I would like to avoid making read-write copy of read-only file on mobile targets.

  • Lifetime Qt Champion

    Be it mobile or desktop, if you want to modify your database you'll need a read-write file. Either a copy of an initial database or a constructed one. There's also the possibility of using something like a web service to contain the database but it has other implications

Log in to reply