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 sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, declarative_base
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# URL-encode the password
|
||||
password = quote_plus("33Pippin!!;")
|
||||
DATABASE_URL = f"postgresql+psycopg2://admin:{password}@voo8ccgwss0ks0000occko4s:5432/postgres"
|
||||
# ---- Use environment variables from Coolify ----
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
DB_PASSWORD = quote_plus(os.getenv("DB_PASSWORD"))
|
||||
DB_HOST = os.getenv("DB_HOST")
|
||||
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)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Base = declarative_base()
|
||||
|
|
|
|||
Loading…
Reference in a new issue