Results 1 to 6 of 6

Thread: SQLite-DB in a qrc file

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default SQLite-DB in a qrc file

    Hi,

    because I want to protect my SQLite-Database file, and don't whant the encryption module because it is then 50% slower, I thougt if it is possible to store my file in the executable itself.

    I know, this does only make sens if:
    - only reading the database
    - the file size is not too big

    So, storing the file (test.db alias embeddb) in the qrc makes no problem. But normaly you assign the db via set setDatabaseName( const QString & name ), but if I try so
    Qt Code:
    1. setDatabaseName(":embeddb");
    To copy to clipboard, switch view to plain text mode 
    there is created a file named `:embeddb`. Is there any possibility to pass something like a path to the qrc stored file?


    Thanks
    Lykurg

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SQLite-DB in a qrc file

    I don't think so. Sqlite database is accessed by the sqlite library and not by Qt routines, so the mechanism has to be supported by sqlite and obviously embed qt resources are not.

  3. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: SQLite-DB in a qrc file

    Looking at the sqlite source, I imagine you would have to implement your own os_xxxxx.c file (which handles file I/O) to hook into Qt's resource file system, and then recompile the QSQLite sql driver. Or write your own separate sql driver for this hacked up sqlite. Good luck with that.

    Maybe you can just embed the db in the exe, then when you need it, extract the db from the .exe to an external file first, and then open it through regular channels (setDatabaseName(), etc)? And delete it when you're done. Could be pretty slow with a big db. I know, pretty bad idea.
    Last edited by gfunk; 29th July 2006 at 01:09.
    Software Engineer



  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SQLite-DB in a qrc file

    Quote Originally Posted by gfunk
    Looking at the sqlite source, I imagine you would have to implement your own os_xxxxx.c file (which handles file I/O) to hook into Qt's resource file system, and then recompile the QSQLite sql driver. Or write your own separate sql driver for this hacked up sqlite. Good luck with that.
    I also have looked in the SQLite sources, and decided that this is a job for someone who really knows what he is doing. So I am out! But if someone has time and would like to do so, I just can say: Go, go, go!

    Lykurg

  5. #5
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: SQLite-DB in a qrc file

    Sounds like a nifty thing to do, but you'd have to convince people:
    1) how useful is a read-only database that can only be modified when you re-compile the executable?

    2) do you actually gain any security by embedding the db as a resource inside the executable? I wonder if there are any tools out there to extract the Qt resources out of an exe (and maybe add/update new resources into the exe?)?

    Btw, just curious since I'm also using sqlite and still rather new to it, how do you turn on encryption in sqlite ? do you use sqlitesecure?
    Last edited by gfunk; 31st July 2006 at 19:35.
    Software Engineer



  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: SQLite-DB in a qrc file

    Well,

    somtimes I want, that not all poeple can see at once my data, which I put in my apps. So simple text files one could encrypt and put them in addition in the Qt resources. As you have remebered, it is possible to extract the data out of the exe, but this needs know-how. I know, that an embedded database / file which is delivered with our application can never be 100% secure, but as above-mentioned I only want that the datafiles are not recognized as datafiles at once and that they can't be easy accessed. The advantage by embedding the file in the qt resource system is, that you do not see the files (no security gain).

    I don't use sqlitesecure. Sorry. At time I just inform me, how (low) data-protection is possible. That the encrypted database is about 50% slower, you could read at http://www.hwaci.com/sw/sqlite/prosupport.html.

    And if embedding the database in the qt resource system, one could write a library for that stuff, so you have just to update this, if you change anything in your data.

    Where one could use it:
    - You have an huge dictionary file, which users can access via Internet, where they do not the the hole file.
    - Now you want to make an offline version. So you have to publish the file, and 2 days later you find a lot of sites, which have occupied your data without saying where they have the data from. Thats not nice, so you have to protect the data, that other cannot access the data easily.
    - Now you can develop an GPL'd application this the library, which embed the database, but you don't deliver the database with your sourcecode. Instead you offer the precompiled library for free download. (Dont know if this is exactly possible under GPL?)
    In that case the database is not very huge (about 2-3 MB), and you only need read-access. (And normal users can't see the data.)

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 12:47
  2. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 15:16
  3. QHttp GET File & Password
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 11th June 2006, 14:04
  4. Accessing DTD in an XML file via QtXml module?
    By jorma in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2006, 19:09
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.