Update app/database.py
This commit is contained in:
parent
1ef636cc0a
commit
20d41c561d
1 changed files with 8 additions and 7 deletions
|
|
@ -1,17 +1,18 @@
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, declarative_base
|
from sqlalchemy.orm import sessionmaker, declarative_base
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
load_dotenv()
|
# ---- Use environment variables from Coolify ----
|
||||||
|
DB_USER = os.getenv("DB_USER")
|
||||||
# URL-encode the password
|
DB_PASSWORD = quote_plus(os.getenv("DB_PASSWORD"))
|
||||||
password = quote_plus("33Pippin!!;")
|
DB_HOST = os.getenv("DB_HOST")
|
||||||
DATABASE_URL = f"postgresql+psycopg2://admin:{password}@voo8ccgwss0ks0000occko4s:5432/postgres"
|
DB_PORT = os.getenv("DB_PORT", "5432")
|
||||||
|
DB_NAME = os.getenv("DB_NAME", "postgres")
|
||||||
|
|
||||||
|
DATABASE_URL = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
||||||
|
|
||||||
|
# ---- SQLAlchemy setup ----
|
||||||
engine = create_engine(DATABASE_URL)
|
engine = create_engine(DATABASE_URL)
|
||||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue