Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Shipping SQLite database with application
Forum Updated to NodeBB v4.3 + New Features

Shipping SQLite database with application

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 655 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mleoni
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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 )

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mleoni
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved