from decouple import config
from sqlmodel import Session, SQLModel, create_engine

DATABASE_URL = config("DATABASE_URL")
DEBUG = config("DEBUG", default=False, cast=bool)


engine = create_engine(DATABASE_URL, echo=DEBUG)


def get_session():
    with Session(engine) as session:
        yield session


def create_db_and_tables():
    SQLModel.metadata.create_all(engine)

sqlmodel.SQLModel.metadata.create_all decouple.config sqlmodel.Session sqlmodel.create_engine
[((98, 120), 'decouple.config', 'config', (['"""DATABASE_URL"""'], {}), "('DATABASE_URL')\n", (104, 120), False, 'from decouple import config\n'), ((129, 170), 'decouple.config', 'config', (['"""DEBUG"""'], {'default': '(False)', 'cast': 'bool'}), "('DEBUG', default=False, cast=bool)\n", (135, 170), False, 'from decouple import config\n'), ((182, 221), 'sqlmodel.create_engine', 'create_engine', (['DATABASE_URL'], {'echo': 'DEBUG'}), '(DATABASE_URL, echo=DEBUG)\n', (195, 221), False, 'from sqlmodel import Session, SQLModel, create_engine\n'), ((336, 372), 'sqlmodel.SQLModel.metadata.create_all', 'SQLModel.metadata.create_all', (['engine'], {}), '(engine)\n', (364, 372), False, 'from sqlmodel import Session, SQLModel, create_engine\n'), ((252, 267), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (259, 267), False, 'from sqlmodel import Session, SQLModel, create_engine\n')]