import os

from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from dotenv import load_dotenv

load_dotenv()


def start_engine():
    database = os.getenv('aws_postgres_db'),
    user = os.getenv('aws_postgres_username'),
    password = os.getenv('aws_postgres_password'),
    host = os.getenv('aws_postgres_endpoint'),
    port = '5432'
    db_engine = create_engine(f'postgresql://{user[0]}:{password[0]}@{host[0]}:5432/{database[0]}')
    return db_engine


engine = start_engine()

Session = sessionmaker(bind=engine)

Base = declarative_base(sessionmaker())
Base.metadata.create_all(engine)
