import os
from venv import create
from sqlmodel import SQLModel, create_engine
from .base_variables import APPNAME,DEBUG
from utils import print_warning
import sys
if DEBUG:
    PG_HOST: str = os.getenv("PGHOST", "localhost")
    PG_USER: str = os.getenv("PGUSER", "postgres")
    PG_PASSWORD: str = os.getenv("PGPASSWORD", "<PASSWORD>")
    PG_PORT: str = os.getenv("PGPORT", "5432")
    PG_DATABASE:str = os.getenv("PGDATABASE", APPNAME)
    DATABASE_URL:str = os.getenv("DATABASE_URL", f"postgresql://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DATABASE}")
else:
    DATABASE_URL = os.getenv("DATABASE_URL", "")
if not DATABASE_URL:
    print_warning(
        (
            "You are not setting the DATABASE_URL in your environment!",
        )
    )
    sys.exit("[ERROR] Default DATABASE_URL is not set\n")
print(DATABASE_URL)
dbengine = 