Spaces:
Sleeping
Sleeping
File size: 560 Bytes
1161dd2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import sqlite3
from sqlite3 import Connection
from server.constant.constants import SQLITE_DB_DIR, SQLITE_DB_NAME
def get_db_connection() -> Connection:
"""
Establishes and returns a connection to the SQLite database.
Returns:
Connection: A connection to the SQLite database.
"""
conn = sqlite3.connect(f"{SQLITE_DB_DIR}/{SQLITE_DB_NAME}")
# Set row factory to access columns by name
conn.row_factory = sqlite3.Row
# Enable WAL mode for better concurrency
conn.execute("PRAGMA journal_mode=WAL;")
return conn
|