Skip to content

Commit

Permalink
Use url creator
Browse files Browse the repository at this point in the history
  • Loading branch information
stefpiatek committed Jan 3, 2024
1 parent 41cc235 commit 720a1ea
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions postgres/create_pixl_tbls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 720a1ea

Please sign in to comment.