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. How To Hide A Source File(.db)
Forum Updated to NodeBB v4.3 + New Features

How To Hide A Source File(.db)

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 694 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.
  • qazaq408Q Offline
    qazaq408Q Offline
    qazaq408
    wrote on last edited by aha_1980
    #1

    qt5.7 + sqlite3

    My programme need some data when it's running. That data is a lot ,and programme need read data frequently,So I write data to database(sqlite3),And then ,I put the file in sourcefile like this.

    /<RCC>
      <qresource>
         ..........
         <file>DataFile/SystemPix.db</file>
         .........
      </qresource>
    </RCC>
    

    And I connect sqlite3 in the progamme

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabase(":/DataFile/SystemPix.db");
    if(!(db.open())
        qDebug()<<"Can't Connect Database.";
    

    As you see,progamme tell me "Can't Connect Database.".....
    Someone tell me do like this

    QFile fs(databaseFile);   //databaseFile is a path of file  like "/home/MyPro/RecordCard/Ds/pix.db"
    if(!(fs.exist()))
        QFile::copy(":/DataFile/SystemPix.db",databaseFile);
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabase(databaseFile);
    //...
    //..
    

    And then , I can connect the database,but this is a problem , user can look the data but I hope hide the data to user, even I delete the file when progamme is over , user also can look file(.db) when progamme is running.
    How could I hide the Data?If I don't copy file to some dir ,progamme can't connect the database(.db file),if I copy file to some dir,user can look at the data,do you have any good idea?

    [Edit aha_1980: fixed title]

    raven-worxR JonBJ 2 Replies Last reply
    0
    • qazaq408Q qazaq408

      qt5.7 + sqlite3

      My programme need some data when it's running. That data is a lot ,and programme need read data frequently,So I write data to database(sqlite3),And then ,I put the file in sourcefile like this.

      /<RCC>
        <qresource>
           ..........
           <file>DataFile/SystemPix.db</file>
           .........
        </qresource>
      </RCC>
      

      And I connect sqlite3 in the progamme

      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      db.setDatabase(":/DataFile/SystemPix.db");
      if(!(db.open())
          qDebug()<<"Can't Connect Database.";
      

      As you see,progamme tell me "Can't Connect Database.".....
      Someone tell me do like this

      QFile fs(databaseFile);   //databaseFile is a path of file  like "/home/MyPro/RecordCard/Ds/pix.db"
      if(!(fs.exist()))
          QFile::copy(":/DataFile/SystemPix.db",databaseFile);
      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      db.setDatabase(databaseFile);
      //...
      //..
      

      And then , I can connect the database,but this is a problem , user can look the data but I hope hide the data to user, even I delete the file when progamme is over , user also can look file(.db) when progamme is running.
      How could I hide the Data?If I don't copy file to some dir ,progamme can't connect the database(.db file),if I copy file to some dir,user can look at the data,do you have any good idea?

      [Edit aha_1980: fixed title]

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @qazaq408
      my guess is, that the sql driver needs write access to the DB file.
      Even if you don't plan to update/alter the data in the DB directly, the DB itself handles some stuff in the back and needs to keep it's state consistent and writes some stuff into the db file.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • qazaq408Q qazaq408

        qt5.7 + sqlite3

        My programme need some data when it's running. That data is a lot ,and programme need read data frequently,So I write data to database(sqlite3),And then ,I put the file in sourcefile like this.

        /<RCC>
          <qresource>
             ..........
             <file>DataFile/SystemPix.db</file>
             .........
          </qresource>
        </RCC>
        

        And I connect sqlite3 in the progamme

        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabase(":/DataFile/SystemPix.db");
        if(!(db.open())
            qDebug()<<"Can't Connect Database.";
        

        As you see,progamme tell me "Can't Connect Database.".....
        Someone tell me do like this

        QFile fs(databaseFile);   //databaseFile is a path of file  like "/home/MyPro/RecordCard/Ds/pix.db"
        if(!(fs.exist()))
            QFile::copy(":/DataFile/SystemPix.db",databaseFile);
        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabase(databaseFile);
        //...
        //..
        

        And then , I can connect the database,but this is a problem , user can look the data but I hope hide the data to user, even I delete the file when progamme is over , user also can look file(.db) when progamme is running.
        How could I hide the Data?If I don't copy file to some dir ,progamme can't connect the database(.db file),if I copy file to some dir,user can look at the data,do you have any good idea?

        [Edit aha_1980: fixed title]

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @qazaq408
        Just how secure (against user looking at file) do you need/expect to be? E.g. do you just want to prevent casual user from easily seeing the file, or do you want to hide it robustly from experienced user/hacker?

        Furthermore/alternatively, are you prepared to pay for software which will protect your data against inspection? And/or are you using SQLite3?

        Pablo J. RoginaP 1 Reply Last reply
        0
        • JonBJ JonB

          @qazaq408
          Just how secure (against user looking at file) do you need/expect to be? E.g. do you just want to prevent casual user from easily seeing the file, or do you want to hide it robustly from experienced user/hacker?

          Furthermore/alternatively, are you prepared to pay for software which will protect your data against inspection? And/or are you using SQLite3?

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @qazaq408 please keep in mind that when you use Qt resource system, the items you add to the RCC file will end up embedded into the executable of your application. The main use of this is to store small icons, translation files, etc.
          So, although nothing prevents you to embed your physical .db file into your app's executable, the SQLite driver is expecting a file in the filesystem that's your first "Can't Connect Database." issue.
          See this similar post with a suggestion for changing the SQLite driver itself to access Qt's resource file system but even if you do that, I guess your DB will be read-only (if not, you'll be updating the executable file every time you write to the DB...)

          How could I hide the Data?

          Have you consider using SQLite encryption extension? spoiler alert: I've never used it myself.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2

          • Login

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