Skip to content

Commit 4d429e5

Browse files
committed
Simplify SQLite session pragmas and drop unused sqlite3 import
1 parent e4bb75c commit 4d429e5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

backend/app/db/session.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
import sqlite3
4-
53
from app.core.config import settings
64
from sqlalchemy import event
75
from sqlalchemy.engine import make_url
@@ -21,15 +19,13 @@
2119

2220
@event.listens_for(engine.sync_engine, "connect")
2321
def _enable_sqlite_pragmas(dbapi_connection, _):
24-
if isinstance(dbapi_connection, sqlite3.Connection):
25-
cursor = dbapi_connection.cursor()
26-
# Always enable FK cascades
27-
cursor.execute("PRAGMA foreign_keys=ON")
28-
# If file-based (not :memory:), WAL improves concurrency
29-
if url.database and url.database not in (":memory:", ""):
30-
cursor.execute("PRAGMA journal_mode=WAL")
31-
cursor.execute("PRAGMA synchronous=NORMAL")
32-
cursor.close()
22+
cursor = dbapi_connection.cursor()
23+
# Always enable FK cascades
24+
cursor.execute("PRAGMA foreign_keys=ON")
25+
# If file-based (not :memory:), WAL improves concurrency
26+
if url.database and url.database not in (":memory:", ""):
27+
cursor.execute("PRAGMA journal_mode=WAL")
28+
cursor.close()
3329

3430

3531
async_session = async_sessionmaker(

0 commit comments

Comments
 (0)