01 August 2008

SQlite3::SQLException: SQL logic error or missing database

SQlite3 errors messages are not very clear ...

"SQlite3::SQLException: SQL logic error or missing database" when inserting should be translated by:
"Invalid id, there is alreay a record in the table with the same id"

In general, we waste a lot of time because libraries authors focus on the "successfull" cases and can't think of all the cases where things can go wrong ...

To play on the safe side, we could try to adopt a defensive programming style and start to write tests (specs) of things which can can fail ...

2 comments:

Dr Nic said...

Oooh thank you for suggesting that root cause. It turned out I was inserting row that violated a UNIQUE constraint.

Cheers, Nic

nublet said...

It can also mean you don't have filesystem permissions to write to the database file.