INNER CODE UNIT · Python
session
BlessedRebuS/Krawl · src/database/core.py:256
def session(self) -> Session:
"""Get a thread-local database session."""
if not self._initialized:
raise RuntimeError(
"DatabaseManager not initialized. Call initialize() first."
)
return self._Session()
@property
def engine(self):
"""The SQLAlchemy Engine, for statements that cannot run in a session.
ANALYZE and friends need connection-level control (AUTOCOMMIT), which a
thread-local ORM session does not give.
"""
if not self._initialized:
raise RuntimeError(
"DatabaseManager not initialized. Call initialize() first."