21 lines
535 B
Python
21 lines
535 B
Python
from sqlalchemy import create_engine
|
|
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 = os.getenv("DATABASE_URL", f"sqlite:///{DB_PATH}")
|
|
|
|
CONNECT_ARGS = {"check_same_thread": False} if DATABASE_URL.startswith("sqlite") else {}
|
|
|
|
engine = create_engine(
|
|
DATABASE_URL,
|
|
connect_args=CONNECT_ARGS
|
|
)
|
|
|
|
SessionLocal = sessionmaker(
|
|
autocommit=False,
|
|
autoflush=False,
|
|
bind=engine
|
|
)
|
|
|
|
Base = declarative_base() |