Skip to content

Commit 734c833

Browse files
author
Saketram Durbha
committed
fix typo in Cloud SQL Postgres sample and refactor SQL Server sample for consistency across Cloud SQL samples
1 parent cf283cf commit 734c833

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cloud-sql/postgres/sqlalchemy/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def init_tcp_connection_engine(db_config):
8383
drivername="postgres+pg8000",
8484
username=db_user, # e.g. "my-database-user"
8585
password=db_pass, # e.g. "my-database-password"
86-
host=db_host, # e.g. "127.0.0.1"
86+
host=db_hostname, # e.g. "127.0.0.1"
8787
port=db_port, # e.g. 5432
8888
database=db_name # e.g. "my-database-name"
8989
),

cloud-sql/sql-server/sqlalchemy/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ def init_tcp_connection_engine():
3838
db_user = os.environ["DB_USER"]
3939
db_pass = os.environ["DB_PASS"]
4040
db_name = os.environ["DB_NAME"]
41+
db_host = os.environ["DB_HOST"]
4142

4243
# Extract host and port from environment variable DB_HOST
43-
host_args = os.environ["DB_HOST"].split(":")
44-
host, port = host_args[0], int(host_args[1])
44+
host_args = db_host.split(":")
45+
db_hostname, db_port = host_args[0], int(host_args[1])
4546

4647
# The SQLAlchemy engine will help manage interactions, including automatically
4748
# managing a pool of connections to your database
@@ -53,8 +54,8 @@ def init_tcp_connection_engine():
5354
username=db_user,
5455
password=db_pass,
5556
database=db_name,
56-
host=host,
57-
port=port,
57+
host=db_hostname,
58+
port=db_port,
5859
query={"driver": "ODBC Driver 17 for SQL Server"},
5960
),
6061
# ... Specify additional properties here.

0 commit comments

Comments
 (0)