""" FILE: modules/web_api/llm/db/connection.py """ import os import sqlite3 # Динамический путь к общей БД в корне проекта BASE_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../")) DB_PATH = os.path.join(BASE_ROOT, "data", "scud_orion_ai.db") def get_db_connection() -> sqlite3.Connection: conn = sqlite3.connect(DB_PATH, timeout=30.0) conn.row_factory = sqlite3.Row conn.execute("PRAGMA foreign_keys = ON;") conn.execute("PRAGMA journal_mode = WAL;") conn.execute("PRAGMA synchronous = NORMAL;") return conn