[New-bugs-announce] [issue45255] sqlite3.connect() should check if the sqlite file exists and throw a FileNotFoundError if it doesn't

Isaac Boates report at bugs.python.org
Tue Sep 21 06:10:04 EDT 2021


New submission from Isaac Boates <iboates at gmail.com>:

I was just using the sqlite3 package and was very confused when trying to open an sqlite database from a relative path, because the only error provided was:

  File "/path/to/filepy", line 50, in __init__
    self.connection = sqlite3.connect(path)
sqlite3.OperationalError: unable to open database file

It turns out I was just executing Python from the wrong location and therefore my relative path was broken. Not a big problem. But it was confusing because it only throws this generic OperationalError.

Could it instead throw a FileNotFoundError if the db simply doesn't exist at the specified path?

----------
messages: 402309
nosy: iboates
priority: normal
severity: normal
status: open
title: sqlite3.connect() should check if the sqlite file exists and throw a FileNotFoundError if it doesn't
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45255>
_______________________________________


More information about the New-bugs-announce mailing list