wrongmove/crawler/database.py

14 lines
555 B
Python

from sqlmodel import create_engine, SQLModel
from sqlalchemy.orm import sessionmaker
# PostgreSQL example (or use "sqlite:///database.db" for SQLite)
# DATABASE_URL = "postgresql://user:password@localhost/db_name"
DATABASE_URL = "sqlite:///data/wrongmove.db"
engine = create_engine(DATABASE_URL, echo=True) # `echo=True` for debug logs
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def init_db():
"""Create all tables (only for development; use migrations in production)."""
SQLModel.metadata.create_all(engine)