[Interest] SQLite: mystic bug: No query Unable to fetch row error

Scott Bloom scott at towel42.com
Thu Jan 14 17:44:42 CET 2021


Prepare can fail if the db is not open, or if the statement has problems that can be found during the compilation of the command. Usually they are static, so I often only check the results in a debug build, not a release one.

For SQLLite, I have often found improperly setup file based databases, often return "no connection" or "unable to fetch" for a multitude of issues


Scott
-----Original Message-----
From: Alexander Dyagilev [mailto:alervdvcw at gmail.com] 
Sent: Thursday, January 14, 2021 08:41
To: Scott Bloom <scott at towel42.com>; interest at qt-project.org
Subject: Re: [Interest] SQLite: mystic bug: No query Unable to fetch row error

On 1/14/2021 7:06 PM, Scott Bloom wrote:
> Did the prepare fail?

No. But why should it fail?

> Do you check to see that the "m_db" database is valid, open, and connected?

No. However it should be opened. Anyway, in these cases the error should be different, isn't it?



>
> Scott
>
> -----Original Message-----
> From: Interest [mailto:interest-bounces at qt-project.org] On Behalf Of Alexander Dyagilev
> Sent: Thursday, January 14, 2021 07:19
> To: interest at qt-project.org
> Subject: [Interest] SQLite: mystic bug: No query Unable to fetch row error
>
> Hello,
>
> Each instance of our app is supposed to have an unique id (UUID).
>
> At every start, it check if it has assigned one, and if not - generates it and saves it to the SQLite database.
>
> We've found, that 4% of ours users has empty UUIDs.
>
> We've added some diagnostic reporting info and found, that this is caused by SQLite database not being able to write generated UUID to it.
>
> QSqlQuery::exec returns false and its last error returns this error "No query Unable to fetch row error".
>
> How can this be? I could not find any problems working with the database in our code.
>
> We do it so:
>
> 1. Make sure the table exists:
>
> "CREATE TABLE IF NOT EXISTS miscData (Name TEXT, Value BLOB, PRIMARY KEY (Name))"
>
> 2. Write value to the table:
>
> QSqlQuery query(m_db);
> query.prepare("REPLACE INTO miscData (Name, Value) VALUES (:Name, :Value)"); query.bindValue(":Name", "UUID"); query.bindValue(":Value", UuidByteArray);
>
> if (!query.exec())
> {
>        // here we're getting this error....
> }
>
> What are the possible reasons of this error?
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list