INNER CODE UNIT · Python
set_sqlite_pragma
BlessedRebuS/Krawl · src/database/core.py:219
def set_sqlite_pragma(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA journal_mode=WAL")
cursor.execute("PRAGMA busy_timeout=30000")
cursor.execute("PRAGMA synchronous=NORMAL")
cursor.execute("PRAGMA wal_autocheckpoint=5000")
cursor.close()
# Create session factory with scoped_session for thread safety
session_factory = sessionmaker(bind=self._engine)
self._Session = scoped_session(session_factory)
# Create all tables
Base.metadata.create_all(self._engine)
# Run migrations (dialect-agnostic via SQLAlchemy Inspector)
from migrations.runner import run_migrations