from api_configs import WagDatabase
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base


engine_config = {
    "url": WagDatabase.DATABASE_URL,
    "pool_size": 20,
    "max_overflow": 10,
    "echo": True,
    "echo_pool": True,
    "isolation_level": "READ COMMITTED",
    "pool_pre_ping": True,
}

engine = create_engine(
    **engine_config,
)
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
session = scoped_session(sessionmaker(bind=engine))

Base = declarative_base()
Base.session = session
