According to the docs (http://luasqlite.luaforge.net/lsqlite3.html#sqlite3.open)
In case of an error, the function returns nil, an error code and an error message.
But I always get the same results no matter if I provide a valid or invalid SQLite file. In fact, if I provide an inexistent file or an invalid path I still get the same results. For example:
db, code, msg = sqlite3.open("foo"))
print(db) -- sqlite database (0x7f9ab1628598)
print(code) -- nil
print(msg) -- nil
How can I catch these errors?
sqlite3.open
"opens (or creates if it does not exist)". If you want to generate an error, trysqlite3.open("/foo")
if you're running some kind of Unix. This should give you apermission denied
error. – lhfpcall
orxpcall
? – David Unric