SQLite and C++
Hello linux brothers,
I'm having a weird problem with SQLite on linux... The code is fine, it compiles and all but I can't read back the dummy value I've inserted into the table. I'm warning you, this is wild code because I always try to get things to work first, I clean it up when that's done: Code:
QSqlDatabase *db = QSqlDatabase::addDatabase("QSQLITE"); Opening database = 1 LastQuery CREATE= LastQuery INSERT= LastQuery SELECT= QSqlQuery::value: not positioned on a valid record LastQuery VALUE= (null) *** Exited normally *** I tried to have a look into the database using the command line tool sqlite3 and I can open the database fine, but when I try the following: /debug/src> sqlite3 TeST.db SQLite version 3.3.8 Enter ".help" for instructions sqlite> SELECT * FROM Test; SQL error: file is encrypted or is not a database sqlite> .quit /debug/src> Now, I didn't encrypt the database, I swear to God!! Manu |
Forget it
I hate to do this again, but I figured it out after all.
When I post here, I expect a prompt answer while I keep on searching on my end. And for the third time in 24h, I won the race. Here's the changed part for the record: Code:
qDebug( "LastQuery SELECT= %s", str.ascii() ); |
Incompatible versions
Hi ManuPeng
You probably have different versions of SQLite included in qt vs. the command line tools I'm guessing that Qt's database wrapper is linked against an older version of SQLite (2.8.2), and from what I see you are using the SQLite 3.3.8 command line tools. /Kristofer EDIT: For the second time in 30min I'm late posting my answer :(, although this time my answer seems to complete yours, or? |
Yeah, thanks!
You're right, your answer does complete mine, thanks for your help.
Your post made me realize that Qt3 still uses SQLite2 whereas the command line tool uses SQLite3, so that's certainly it. I think there's a command line tool for SQLite2 on the DVD, I sort of remember seeing it. From what I've read, Qt4 will implement SQLite3 which I like because it allows BLOBs and SQLite2 apparently doesn't. So I'll have to encode/decode in base64. I want to wait for a stable KDE4 release before I start messing up with my system. If it ain't broke... Manu |
I confirm, it does it, the different versions of the SQLite used in Qt3 and in the command line tool was the problem. All good now!
|
All times are GMT -5. The time now is 09:05 AM. |