#!/usr/bin/env python3

from sqlalchemy.orm import sessionmaker
from sqlmodel import create_engine

from . import constants

#postgres_url = f"postgresql://postgres:{constants.POSTGRES_PW}@localhost/billsim"
if constants.POSTGRES_URL is None:
    postgres_url = f"postgresql://postgres:{constants.POSTGRES_PW}@localhost"
else:
    postgres_url = constants.POSTGRES_URL

engine = create_engine(postgres_url, echo=True)

SessionLocal = sessionmaker(autocommit=False,
                            autoflush=False,
                            expire_on_commit=False,
                            bind=engine)

sqlalchemy.orm.sessionmaker sqlmodel.create_engine
[((379, 417), 'sqlmodel.create_engine', 'create_engine', (['postgres_url'], {'echo': '(True)'}), '(postgres_url, echo=True)\n', (392, 417), False, 'from sqlmodel import create_engine\n'), ((434, 522), 'sqlalchemy.orm.sessionmaker', 'sessionmaker', ([], {'autocommit': '(False)', 'autoflush': '(False)', 'expire_on_commit': '(False)', 'bind': 'engine'}), '(autocommit=False, autoflush=False, expire_on_commit=False,\n    bind=engine)\n', (446, 522), False, 'from sqlalchemy.orm import sessionmaker\n')]