sqlitedict icon indicating copy to clipboard operation
sqlitedict copied to clipboard

Loading a corrupted database does not raise exception gracefully

Open mtanti opened this issue 5 years ago • 2 comments

If you try to load a file which isn't a database, you get the following error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "...\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "...\lib\site-packages\sqlitedict.py", line 396, in run
    conn.execute('PRAGMA journal_mode = %s' % self.journal_mode)
sqlite3.DatabaseError: file is not a database

The problem here is that the error raises in a thread which then dies and leave your console hanging, probably due to missing multithread error handling.

I find it strange that I should get multithreading when I use SqliteDict and not SqliteMultithread, which I traced to the _new_conn method. A quick fix would be to avoid using multithreading when none is requested in order to avoid this sort of error when not using multithreading at least.

mtanti avatar Jan 09 '21 12:01 mtanti

Thanks for reporting @mtanti . Will you be able to look into this, submit a PR?

piskvorky avatar Jan 09 '21 22:01 piskvorky

Thanks for reporting @mtanti . Will you be able to look into this, submit a PR?

No I don't have time, sorry.

mtanti avatar Jan 10 '21 14:01 mtanti