Skip to content

Personal AI, On Personal Devices

Python

fix: add check_same_thread=False to all SQLite connections (#176)

Avanika Narayan867a96fd6ebb
diff --git a/src/openjarvis/learning/optimize/store.py b/src/openjarvis/learning/optimize/store.py
index 8841384f..7d1eb7ef 100644
--- a/src/openjarvis/learning/optimize/store.py
+++ b/src/openjarvis/learning/optimize/store.py
@@ -92,7 +92,7 @@ class OptimizationStore:
def __init__(self, db_path: Union[str, Path]) -> None:
self._db_path = str(db_path)
- self._conn = sqlite3.connect(self._db_path)
+ self._conn = sqlite3.connect(self._db_path, check_same_thread=False)
self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute(_CREATE_RUNS)
self._conn.execute(_CREATE_TRIALS)
diff --git a/src/openjarvis/security/audit.py b/src/openjarvis/security/audit.py
index 06a68d30..888fe160 100644
--- a/src/openjarvis/security/audit.py
+++ b/src/openjarvis/security/audit.py
@@ -39,7 +39,7 @@ class AuditLogger:
from openjarvis.security.file_utils import secure_create
secure_create(self._db_path)
- self._conn = sqlite3.connect(str(self._db_path))
+ self._conn = sqlite3.connect(str(self._db_path), check_same_thread=False)
self._conn.execute(
"""
CREATE TABLE IF NOT EXISTS security_events (
diff --git a/src/openjarvis/telemetry/aggregator.py b/src/openjarvis/telemetry/aggregator.py
index f4beee43..ead6c5ed 100644
--- a/src/openjarvis/telemetry/aggregator.py
+++ b/src/openjarvis/telemetry/aggregator.py
@@ -89,7 +89,7 @@ class TelemetryAggregator:
def __init__(self, db_path: str | Path) -> None:
self._db_path = str(db_path)
- self._conn = sqlite3.connect(self._db_path)
+ self._conn = sqlite3.connect(self._db_path, check_same_thread=False)
self._conn.row_factory = sqlite3.Row
@staticmethod
diff --git a/src/openjarvis/tools/storage/knowledge_graph.py b/src/openjarvis/tools/storage/knowledge_graph.py
index 4890de61..9daa68db 100644
--- a/src/openjarvis/tools/storage/knowledge_graph.py
+++ b/src/openjarvis/tools/storage/knowledge_graph.py
@@ -60,7 +60,7 @@ class KnowledgeGraphMemory:
) -> None:
self._db_path = Path(db_path)
self._db_path.parent.mkdir(parents=True, exist_ok=True)
- self._conn = sqlite3.connect(str(self._db_path))
+ self._conn = sqlite3.connect(str(self._db_path), check_same_thread=False)
self._create_tables()
def _create_tables(self) -> None: