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. Problem with DB connection on iOS
Qt 6.11 is out! See what's new in the release blog

Problem with DB connection on iOS

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 2 Posters 2.1k 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.
  • R Offline
    R Offline
    rezedare
    wrote on last edited by
    #1

    I'm trying to connect my application to a SQLite database and it's OK on desktop and Android but fails on iOS with the following error: "out of memory Error opening database".

    Don't know how to solve that.

    Help me, please!

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

      Hi and welcome to devnet,

      What is the size of your database and what is it's path ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rezedare
        wrote on last edited by
        #3

        Hi,

        Database consist of one table with one record and it's size 3KB.

        It lies in /Users/user/Qt5.2.1/5.2.1/Projects/QtNetworkExample/db/my_db.sqlite and I include this file to my resource files. Also database is in build files(/Users/user/iOS/Qt5.2.1/5.2.1/Projects/build-QtNetworkExample-iphoneos_clang_Qt_5_2_1_for_iOS-Release).

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can't access a Sqlite database file on your computer from your device. You need to put it somewhere allowed using QStandardPaths and access it there

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rezedare
            wrote on last edited by
            #5

            Thanks, SGaist!
            It works now on iOS, but not on Android. Can you explain, please, why so?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Without seeing the code, I can't guess

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rezedare
                wrote on last edited by
                #7

                Code for iOS is the following:
                @QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
                qDebug() << paths;
                QString dbFile = paths.first().append("/my_db");
                QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
                database.setDatabaseName(dbFile);

                if (!database.open()) {
                    qDebug() << "An error occurred while opening the connection: " << database.lastError().text();
                }@
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What error are you getting now ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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