diff --git a/database/database.py b/database/database.py index a59806f..020ad33 100644 --- a/database/database.py +++ b/database/database.py @@ -3,11 +3,14 @@ from sqlalchemy.orm import sessionmaker, declarative_base import os DB_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "regwatch.db") -DATABASE_URL = f"sqlite:///{DB_PATH}" +DATABASE_URL = os.getenv("DATABASE_URL", f"sqlite:///{DB_PATH}") + +# check_same_thread est propre à SQLite : psycopg2 le rejette. +CONNECT_ARGS = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {} engine = create_engine( DATABASE_URL, - connect_args={"check_same_thread": False} + connect_args=CONNECT_ARGS ) SessionLocal = sessionmaker( diff --git a/requirements.txt b/requirements.txt index b8eb833..34e56e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ ollama python-jose[cryptography] passlib[argon2] python-multipart -pdfplumber \ No newline at end of file +pdfplumber +psycopg2-binary