# database/connection.py import os import sqlite3 DB_PATH = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "bot.db" ) def get_conn() -> sqlite3.Connection: conn = sqlite3.connect(DB_PATH, timeout=30, check_same_thread=False) conn.execute("PRAGMA journal_mode=WAL") conn.execute("PRAGMA cache_size=-32768") conn.execute("PRAGMA synchronous=NORMAL") conn.execute("PRAGMA foreign_keys=ON") conn.execute("PRAGMA temp_store=MEMORY") conn.row_factory = sqlite3.Row return conn