3232
3333def init_tcp_connection_engine ():
3434 # [START cloud_sql_server_sqlalchemy_create_tcp]
35+ # [START cloud_sql_sqlserver_sqlalchemy_create_tcp]
3536 # Remember - storing secrets in plaintext is potentially unsafe. Consider using
3637 # something like https://cloud.google.com/secret-manager/docs/overview to help keep
3738 # secrets secret.
@@ -61,32 +62,41 @@ def init_tcp_connection_engine():
6162 # ... Specify additional properties here.
6263 # [START_EXCLUDE]
6364 # [START cloud_sql_server_sqlalchemy_limit]
65+ # [START cloud_sql_sqlserver_sqlalchemy_limit]
6466 # Pool size is the maximum number of permanent connections to keep.
6567 pool_size = 5 ,
6668 # Temporarily exceeds the set pool_size if no connections are available.
6769 max_overflow = 2 ,
6870 # The total number of concurrent connections for your application will be
6971 # a total of pool_size and max_overflow.
72+ # [END cloud_sql_sqlserver_sqlalchemy_limit]
7073 # [END cloud_sql_server_sqlalchemy_limit]
7174 # [START cloud_sql_server_sqlalchemy_backoff]
75+ # [START cloud_sql_sqlserver_sqlalchemy_backoff]
7276 # SQLAlchemy automatically uses delays between failed connection attempts,
7377 # but provides no arguments for configuration.
78+ # [END cloud_sql_sqlserver_sqlalchemy_backoff]
7479 # [END cloud_sql_server_sqlalchemy_backoff]
7580 # [START cloud_sql_server_sqlalchemy_timeout]
81+ # [START cloud_sql_sqlserver_sqlalchemy_timeout]
7682 # 'pool_timeout' is the maximum number of seconds to wait when retrieving a
7783 # new connection from the pool. After the specified amount of time, an
7884 # exception will be thrown.
7985 pool_timeout = 30 , # 30 seconds
86+ # [END cloud_sql_sqlserver_sqlalchemy_timeout]
8087 # [END cloud_sql_server_sqlalchemy_timeout]
8188 # [START cloud_sql_server_sqlalchemy_lifetime]
89+ # [START cloud_sql_sqlserver_sqlalchemy_lifetime]
8290 # 'pool_recycle' is the maximum number of seconds a connection can persist.
8391 # Connections that live longer than the specified amount of time will be
8492 # reestablished
8593 pool_recycle = 1800 , # 30 minutes
94+ # [END cloud_sql_sqlserver_sqlalchemy_lifetime]
8695 # [END cloud_sql_server_sqlalchemy_lifetime]
8796 echo = True # debug
8897 # [END_EXCLUDE]
8998 )
99+ # [END cloud_sql_sqlserver_sqlalchemy_create_tcp]
90100 # [END cloud_sql_server_sqlalchemy_create_tcp]
91101
92102 return pool
@@ -148,6 +158,7 @@ def save_vote():
148158 return Response (response = "Invalid team specified." , status = 400 )
149159
150160 # [START cloud_sql_server_sqlalchemy_connection]
161+ # [START cloud_sql_sqlserver_sqlalchemy_connection]
151162 # Preparing a statement before hand can help protect against injections.
152163 stmt = sqlalchemy .text (
153164 "INSERT INTO votes (time_cast, candidate)"
@@ -169,6 +180,7 @@ def save_vote():
169180 "application logs for more details." ,
170181 )
171182 # [END_EXCLUDE]
183+ # [END cloud_sql_sqlserver_sqlalchemy_connection]
172184 # [END cloud_sql_server_sqlalchemy_connection]
173185
174186 return Response (
0 commit comments