From 720a1eacc01514e3495f933f7c97594687ef324c Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 3 Jan 2024 15:44:16 +0000 Subject: [PATCH] Use url creator --- postgres/create_pixl_tbls.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/postgres/create_pixl_tbls.py b/postgres/create_pixl_tbls.py index eafb7de9a..140d33f6b 100644 --- a/postgres/create_pixl_tbls.py +++ b/postgres/create_pixl_tbls.py @@ -2,12 +2,14 @@ import os from core.database import Base -from sqlalchemy import create_engine +from sqlalchemy import URL, create_engine -user = os.environ["POSTGRES_USER"] -password = os.environ["POSTGRES_PASSWORD"] -DB = os.environ["POSTGRES_DB"] +url = URL.create( + drivername="postgresql+psycopg2", + username=os.environ["POSTGRES_USER"], + password=os.environ["POSTGRES_PASSWORD"], + database=os.environ["POSTGRES_DB"], +) -conn = f"postgresql+psycopg2://{user}:{password}@/{DB}" -engine = create_engine(conn, echo=True, echo_pool="debug") +engine = create_engine(url, echo=True, echo_pool="debug") Base.metadata.create_all(engine)