2025-06-03 20:00:30 +00:00
|
|
|
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"
|
|
|
|
|
|
2025-06-04 21:56:26 +00:00
|
|
|
engine = create_engine(DATABASE_URL, echo=False) # `echo=True` for debug logs
|
2025-06-03 20:00:30 +00:00
|
|
|
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)
|