[SOLVED] Problem with QSqlDatabase
-
Thanks. I tried with that test code, but I get these errors when I try to open the test database to /root/test.db:
@QSqlDatabasePrivate::database: unable to open database: "out of memory Error opening database"
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
"/root/testd.db"@ -
Hi,
Replace the path of the Database with your path.
Which OS are you testing on ? -
I tried to replace it for example with /home/nemo/.local/MyApp which I think is the place where I could store databases with the emulator. I am testing on Sailfish OS emulator on windows 8.
I am a bit unsure also about these paths in Qt-Creator, how should I define the path if I would like to access a directory that the emulator also sees and can access?
-
For paths you could use "StandardLocation":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#StandardLocation-enum of QStandardPaths.
Good to use "QStandardPaths::DataLocation" for data storage.
Check manually if the db file was created atleast in that path. -
In this test code I think database must be opened before you create and execute QSqlQuery.
I am not familiar with Sailfish emulator at all. But you can test whether the problem is only in location of database. Just use the test code from above but for database name use
db.setDatabaseName(":memory:");
This will create temporary database in memory. -
Great, you should
mark the thread as [solved] then ;)