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 = create_engine(DATABASE_URL)

sqlmodel.create_engine os.getenv sys.exit utils.print_warning
[((847, 874), 'sqlmodel.create_engine', 'create_engine', (['DATABASE_URL'], {}), '(DATABASE_URL)\n', (860, 874), False, 'from sqlmodel import SQLModel, create_engine\n'), ((193, 225), 'os.getenv', 'os.getenv', (['"""PGHOST"""', '"""localhost"""'], {}), "('PGHOST', 'localhost')\n", (202, 225), False, 'import os\n'), ((245, 276), 'os.getenv', 'os.getenv', (['"""PGUSER"""', '"""postgres"""'], {}), "('PGUSER', 'postgres')\n", (254, 276), False, 'import os\n'), ((300, 337), 'os.getenv', 'os.getenv', (['"""PGPASSWORD"""', '"""<PASSWORD>"""'], {}), "('PGPASSWORD', '<PASSWORD>')\n", (309, 337), False, 'import os\n'), ((357, 384), 'os.getenv', 'os.getenv', (['"""PGPORT"""', '"""5432"""'], {}), "('PGPORT', '5432')\n", (366, 384), False, 'import os\n'), ((407, 439), 'os.getenv', 'os.getenv', (['"""PGDATABASE"""', 'APPNAME'], {}), "('PGDATABASE', APPNAME)\n", (416, 439), False, 'import os\n'), ((463, 567), 'os.getenv', 'os.getenv', (['"""DATABASE_URL"""', 'f"""postgresql://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DATABASE}"""'], {}), "('DATABASE_URL',\n    f'postgresql://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DATABASE}')\n", (472, 567), False, 'import os\n'), ((589, 618), 'os.getenv', 'os.getenv', (['"""DATABASE_URL"""', '""""""'], {}), "('DATABASE_URL', '')\n", (598, 618), False, 'import os\n'), ((644, 721), 'utils.print_warning', 'print_warning', (["('You are not setting the DATABASE_URL in your environment!',)"], {}), "(('You are not setting the DATABASE_URL in your environment!',))\n", (657, 721), False, 'from utils import print_warning\n'), ((762, 815), 'sys.exit', 'sys.exit', (['"""[ERROR] Default DATABASE_URL is not set\n"""'], {}), "('[ERROR] Default DATABASE_URL is not set\\n')\n", (770, 815), False, 'import sys\n')]