Is it possible to attach an SQLITE database and still use the Qt database classes?
Is it possible to attach an SQLITE database and still use the Qt database classes?
John
Well, you could use the sql statementthen it is pure SQL and has nothing to do with Qt. => You can still use Qt's classes.sql Code:
ATTACH DATABASE filename AS databasenameTo copy to clipboard, switch view to plain text mode
Or you can simply useQt Code:
//...To copy to clipboard, switch view to plain text mode
drescherjm (1st November 2009)
Thanks. I was not sure if that method would work.
Now that I expected to work.Or you can simply useQt Code:
//...To copy to clipboard, switch view to plain text mode
Now the question is mainly can I use 2 databases in the same QSqlQuery? I assume with the ATTACH database sql statement I can do this.
Last edited by drescherjm; 1st November 2009 at 09:50.
John
Hello all!
Regarding the same subject.
It is possible to attach a database that resides into a QTemporaryFile?
Thank you!
Have you tried? Why shouldn't it working? It's a "normal" file. Just use QTemporaryFile::fileName() to work with the file.
with Qt classes you need add two databases using QSqlDatabase::addDatabase, but you need specify different connectionName:
Qt Code:
db1.setDatabaseName("path/to/db1"); db2.setDatabaseName("path/to/db2"); //opening databases and etc.To copy to clipboard, switch view to plain text mode
then you can get data from these databases like this:
Qt Code:
... //preparing query and execution ... //preparing query and execution ...To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
are you sure that your code will work?
the first parameter of QSqlDatabase::addDatabase should be a name of a driver? i.e. should be:
Qt Code:
db.setDatabaseName("path/to/file"); //...To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks