by simonw · 3y ago · 0 comments
import sqlite3
>>> db = sqlite3.connect("data.db")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: unable to open database file
Presumably that operation failed because there isn't a writable virtual filesystem. Would it be possible to provide one? >>> open("data.db", "w+").close()
>>> db = sqlite3.connect("/data.db")
>>> db
<sqlite3.Connection object at 0x8b3fd8>Regular Python doesn't need me to create the file first, I wonder why this works differently.