Re: [sqlite] QT4 ubuntu sqlite driver problem ? (was Re: [sqlite] Weird error)
John Stanton a écrit : Alain Bertrand wrote: In a Qt4 application, I have the following bit of code : QString s; bool b; QSqlQuery q; QSqlError err; s= "CREATE TABLE ttd_bdata (sheetId integer primary key,"; s+="creation_date date, modif_date date,"; s+="speciesId integer,USDA_zone integer,"; s+="generalities text,propagation text,care text,"; s+="esthetics text, phyto text,miscellaneous text)"; //s="SELECT * FROM ttd_species WHERE speciesId=4"; qWarning( s.toAscii() ); b=q.exec( s ); Executing the query fails with the following information SQL logic error or missing database Unable to fetch row Err number 1. I have found the solution in the qt4 doc : - The driver is locked for updates while a select is executed. This may cause problems when using QSqlTableModel because Qt's item views fetch data as needed (with QSqlQuery::fetchMore() in the case of QSqlTableModel). To avoid the problem, one may use the clear() method of the QSqlQuery. Alain - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] QT4 ubuntu sqlite driver problem ? (was Re: [sqlite] Weird error)
Joe Wilson a écrit : --- Alain Bertrand <[EMAIL PROTECTED]> wrote: > --- Alain Bertrand <[EMAIL PROTECTED]> wrote: In a Qt4 application, I have the following bit of code : QString s; bool b; QSqlQuery q; QSqlError err; s= "CREATE TABLE ttd_bdata (sheetId integer primary key,"; s+="creation_date date, modif_date date,"; s+="speciesId integer,USDA_zone integer,"; s+="generalities text,propagation text,care text,"; s+="esthetics text, phyto text,miscellaneous text)"; //s="SELECT * FROM ttd_species WHERE speciesId=4"; qWarning( s.toAscii() ); b=q.exec( s ); Executing the query fails with the following information SQL logic error or missing database Unable to fetch row Err number 1. If the query is remplaced by the commented one, I got no error. If I open my database file with sqliteman, the query is executed without any problem. Some ideas ? I don't understand your description, but here are some random thoughts that might help you: Thanks for your answer. CREATE statements do not return any rows. Yes, so why do I get this message from the qt driver ? Your select table did not match the create statement table. Instead: Use "SELECT * FROM ttd_bdata WHERE speciesId=4" This is not an error. The table is not created so the select on a table which I know does exists is here to prove that I don't have a "missing database" error. To add to obscurity, if I run the same function in a different context, it is ok but very simple queries (like UPDATE ttd_version SET minor='1' WHERE Id=1) fails both in my app and in sqliteman. I would now think of a QT/sqlite driver bug. Does anybody heard of some problem with the sqlite driver in the qt4 libs of Ubuntu feisty ? Don't use += in this case ok. AlainQT4 - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Weird error
Hi all In a Qt4 application, I have the following bit of code : QString s; bool b; QSqlQuery q; QSqlError err; s= "CREATE TABLE ttd_bdata (sheetId integer primary key,"; s+="creation_date date, modif_date date,"; s+="speciesId integer,USDA_zone integer,"; s+="generalities text,propagation text,care text,"; s+="esthetics text, phyto text,miscellaneous text)"; //s="SELECT * FROM ttd_species WHERE speciesId=4"; qWarning( s.toAscii() ); b=q.exec( s ); Executing the query fails with the following information SQL logic error or missing database Unable to fetch row Err number 1. If the query is remplaced by the commented one, I got no error. If I open my database file with sqliteman, the query is executed without any problem. Some ideas ? TIA Alain - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Re: query problem
D. Richard Hipp a écrit : I've changed my mind. I think instead that there is a bug in SQLite that caused LEFT JOINs to be computed incorrectly if one of the terms in the ON clause restricts only the left table in the join. Check-in [2725] at http://www.sqlite.org/cvstrac/chngview?cn=2725 contains a fix for this problem for version 3.x. The problem has existed in SQLite forever (because it originates from a conceptual misunderstanding by the code author :-)) so version 2.8.16 is still broken. Because the problem is obscure, I am not inclined to fix it in the 2.8.x series... Thanks for your answer. Do you have an approximativ dateframe to see this fix incorporated in a release ? Alain
[sqlite] Re: query problem
Puneet Kishor a écrit : without seeing the data, a good guess would be, "Yes." What do you mean ? That my query is syntaxically wrong ? LEFT JOIN selects all the rows with values from the left table and either matching values or NULL from the right table. Yes, I know, not very well because I have only a basic knowledge of sql (this query has been written by a friend), but this is what I want. This may look complicated for just counting the number of rows, but in fact this a kind of minimum example to reproduce the problem I have with a more complex query. Regards, Alain
[sqlite] query problem
hi all, I am porting a program from mysql to sqlite. The following statement doesn't work correctly with sqlite though it does with mysql. SELECT COUNT(*) AS nb FROM ttd_photos LEFT JOIN ttd_trees ON ttd_photos.kind=1 AND ttd_photos.refId=ttd_trees.treeId LEFT JOIN ttd_pots ON ttd_photos.kind=2 AND ttd_photos.refId=ttd_pots.potId In my test case, it reports 0 where it should report 2. This is the LEFT JOIN part which has a problem ;) Any idea ? Thanks, Alain