aboutsummaryrefslogtreecommitdiff
path: root/server/db.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2025-04-28 00:10:57 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2025-04-28 00:10:57 -0600
commit96715ca3ce3817690ac7e4db3fee6062089956c1 (patch)
tree0633718c25b89c8ad0b510d34e667f6448eb6142 /server/db.py
parentd1c1844f6e7a98bf8d593c810afa44fbfdbd8dc1 (diff)
WAL & retry
Diffstat (limited to 'server/db.py')
-rw-r--r--server/db.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/db.py b/server/db.py
index a73d08f..221d240 100644
--- a/server/db.py
+++ b/server/db.py
@@ -1,9 +1,13 @@
-from sqlalchemy import create_engine
+from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker, declarative_base
# SQLite DB
DATABASE_URL = "sqlite:///./virtual_energy.db"
-engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
+engine = create_engine(
+ DATABASE_URL, connect_args={"check_same_thread": False, "timeout": 30}
+)
+with engine.connect() as conn:
+ conn.execute(text("PRAGMA journal_mode=WAL;"))
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()