Skip to content

Commit

Permalink
update (full-stack/sqlmodel): explicit url building
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Aug 11, 2024
1 parent b006e1d commit 8a2fcfe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion full-stack/2-sqlmodel/users_example_3_07.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ class Users(SQLModel, table=True):
user_2 = Users(email_id="doriana@email.com", name="Doriana", birthday=parse_date("2024-03-05"))
user_3 = Users(email_id="bonerges@email.com", name="Bonerges", birthday=parse_date("2024-05-01"))

engine = create_engine("postgresql://postgres:postgres@localhost:5431/test")
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD = "postgres"
POSTGRES_SERVER = "localhost"
POSTGRES_PORT = "5431"
POSTGRES_DB = "test"
POSTGRES_URL = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_SERVER}:{POSTGRES_PORT}/{POSTGRES_DB}"

engine = create_engine(POSTGRES_URL)

SQLModel.metadata.create_all(engine)

Expand Down
9 changes: 8 additions & 1 deletion full-stack/2-sqlmodel/users_example_3_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ class Users(SQLModel, table=True):
user_2 = Users(email_id="doriana@email.com", name="Doriana", birthday=parse_date("2024-03-05"))
user_3 = Users(email_id="bonerges@email.com", name="Bonerges", birthday=parse_date("2024-05-01"))

engine = create_engine("postgresql://postgres:postgres@localhost:5431/test")
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD = "postgres"
POSTGRES_SERVER = "localhost"
POSTGRES_PORT = "5431"
POSTGRES_DB = "test"
POSTGRES_URL = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_SERVER}:{POSTGRES_PORT}/{POSTGRES_DB}"

engine = create_engine(POSTGRES_URL)

SQLModel.metadata.create_all(engine)

Expand Down

0 comments on commit 8a2fcfe

Please sign in to comment.