Switch sqlite clients to only use one connection

This commit is contained in:
Brandon Rising
2023-08-15 21:46:24 -04:00
parent 15e7ca1baa
commit abf09fc8fa
7 changed files with 32 additions and 34 deletions

View File

@ -177,15 +177,13 @@ class BatchProcessStorageBase(ABC):
class SqliteBatchProcessStorage(BatchProcessStorageBase):
_filename: str
_conn: sqlite3.Connection
_cursor: sqlite3.Cursor
_lock: threading.Lock
def __init__(self, filename: str) -> None:
def __init__(self, conn: sqlite3.Connection) -> None:
super().__init__()
self._filename = filename
self._conn = sqlite3.connect(filename, check_same_thread=False)
self._conn = conn
# Enable row factory to get rows as dictionaries (must be done before making the cursor!)
self._conn.row_factory = sqlite3.Row
self._cursor = self._conn.cursor()