Hi - I’m using sqlite on disk as temporary storage, and would like to use
tempfile to create a file for the lifetime of the object, as my calculations are out of memory.
Hereby I presume that the file will be safely deleted once the object is garbage collected. Unfortunately this code raises the error below:
from tempfile import NamedTemporaryFile import sqlite3 class A(object): def __init__(self): self.tempfile = NamedTemporaryFile(suffix='.db') self.conn = sqlite3.connect(self.tempfile.name) obj = A()
The error message:
Traceback (most recent call last): self.conn = sqlite3.connect(self.tempfile.name) sqlite3.OperationalError: unable to open database file Process finished with exit code 1
What am I missing?