RAG_APP / app /db /session.py
GitHub Actions
Sync from GitHub commit: bbc03771
1dc0474
raw
history blame contribute delete
545 Bytes
import sqlite3
from app.core.config import settings
def get_db_connection():
conn = sqlite3.connect(settings.DATABASE_URL, check_same_thread=False)
conn.row_factory = sqlite3.Row
return conn
def init_db():
conn = get_db_connection()
conn.execute('''
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
role TEXT NOT NULL,
content TEXT NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)
''')
conn.commit()
conn.close()