feat(etl): stable pipeline, exception registry in SQLite, multi-pass aggregation and db_cli
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
===============================================================================
|
||||
FILE: core/connection.py
|
||||
PROJECT: SCUD Orion AI (Unified Architecture)
|
||||
ROLE: Единый менеджер подключений к базе данных SQLite (WAL mode, timeouts).
|
||||
===============================================================================
|
||||
"""
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
from config import DATA_DIR
|
||||
|
||||
DB_PATH = os.path.join(DATA_DIR, "scud_orion_ai.db")
|
||||
|
||||
|
||||
def get_connection(row_factory: bool = False) -> sqlite3.Connection:
|
||||
"""
|
||||
Создает оптимизированное подключение к SQLite.
|
||||
row_factory=True возвращает sqlite3.Row для доступа к полям по имени.
|
||||
"""
|
||||
conn = sqlite3.connect(DB_PATH, timeout=30.0)
|
||||
if row_factory:
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.execute("PRAGMA foreign_keys = ON;")
|
||||
conn.execute("PRAGMA journal_mode = WAL;")
|
||||
conn.execute("PRAGMA synchronous = NORMAL;")
|
||||
return conn
|
||||
Reference in New Issue
Block a user