Skip to content

Commit 05d9bcb

Browse files
committed
Add sqlserver private ip ssl app engine connect.
1 parent ff545c2 commit 05d9bcb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def connect_with_connector() -> sqlalchemy.engine.base.Engine:
3535
db_name = os.environ["DB_NAME"] # e.g. 'my-database'
3636

3737
ip_type = IPTypes.PRIVATE if os.environ.get("PRIVATE_IP") else IPTypes.PUBLIC
38+
# [START_EXCLUDE]
39+
if 'DB_ROOT_CERT' in os.environ:
40+
db_root_cert = os.environ["DB_ROOT_CERT"] # e.g. 'certs/server-ca.pem'
41+
else:
42+
db_root_cert = None
43+
# [END_EXCLUDE]
3844

3945
connector = Connector(ip_type)
4046

@@ -45,6 +51,9 @@ def getconn() -> pytds.Connection:
4551
user=db_user,
4652
password=db_pass,
4753
db=db_name,
54+
# [START_EXCLUDE]
55+
cafile=db_root_cert,
56+
# [END_EXCLUDE]
4857
)
4958
return conn
5059

0 commit comments

Comments
 (0)