Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. SQLITE Database in Project
Forum Updated to NodeBB v4.3 + New Features

SQLITE Database in Project

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
sqlite
25 Posts 8 Posters 33.8k Views 2 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.
  • C cawlfj
    18 Feb 2017, 10:38

    @goetz
    some time , we need store a read-only database file in the QRC file. just need read no need change.
    store in qrc file will avoid use change ,delete....etc it. and use database file (qsqlite3 ) will be fast get query result.

    now qt version is 5.8. can we do it ?

    best regards,

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 18 Feb 2017, 10:55 last edited by
    #21

    @cawlfj

    Hi
    If small database, you can just copy
    it to file system upon run and
    open it.

    Just override it each time.

    I do not think its possible to have a db in qrc.

    C 1 Reply Last reply 18 Feb 2017, 15:06
    1
    • M mrjj
      18 Feb 2017, 10:55

      @cawlfj

      Hi
      If small database, you can just copy
      it to file system upon run and
      open it.

      Just override it each time.

      I do not think its possible to have a db in qrc.

      C Offline
      C Offline
      cawlfj
      wrote on 18 Feb 2017, 15:06 last edited by
      #22

      @mrjj yes , you are right . we can do as your way. but i think if the db file in inside the qrc file will be more safety than copy out.
      Some time , some data , we don't want some body to get it .

      M 1 Reply Last reply 18 Feb 2017, 15:30
      0
      • C cawlfj
        18 Feb 2017, 15:06

        @mrjj yes , you are right . we can do as your way. but i think if the db file in inside the qrc file will be more safety than copy out.
        Some time , some data , we don't want some body to get it .

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 18 Feb 2017, 15:30 last edited by
        #23

        @cawlfj
        Well its not impossible to still dig it out using a hex editor.
        For dbs, something like
        https://www.zetetic.net/sqlcipher/about/
        might be better.
        Maybe you can use the dump trick to upload to a :mem based db.
        http://stackoverflow.com/questions/3826552/in-python-how-can-i-load-a-sqlite-db-completely-to-memory-before-connecting-to
        Disclaimer: i never tried this.

        1 Reply Last reply
        2
        • E Offline
          E Offline
          EdgarDinz
          wrote on 3 Oct 2019, 18:08 last edited by EdgarDinz 10 Mar 2019, 18:10
          #24

          Consider using QTemporaryFile::createNativeFile:

          QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file)
          QTemporaryFile *QTemporaryFile::createNativeFile(const QString &fileName)
          

          then you can pass a resource path as fileName.

          1 Reply Last reply
          0
          • G goetz
            24 Feb 2011, 11:56

            SQLite databases cannot be stored in the Qt resource system. You must put it into regular files and distribute them along your application.

            The reason is simple: The database name is just the path to the file. Qt does not intercept the file name but hands it over directly to the SQLite functions (by calling toUtf8() on the “path”), which in turn try to open that file – and will eventually fail, of course.

            A Offline
            A Offline
            an_auto
            wrote on 2 Dec 2020, 11:05 last edited by
            #25
            This post is deleted!
            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