3131
3232
3333def init_tcp_connection_engine ():
34- # [START cloud_sql_server_sqlalchemy_create_tcp]
3534 # [START cloud_sql_sqlserver_sqlalchemy_create_tcp]
3635 # Remember - storing secrets in plaintext is potentially unsafe. Consider using
3736 # something like https://cloud.google.com/secret-manager/docs/overview to help keep
@@ -61,7 +60,6 @@ def init_tcp_connection_engine():
6160 ),
6261 # ... Specify additional properties here.
6362 # [START_EXCLUDE]
64- # [START cloud_sql_server_sqlalchemy_limit]
6563 # [START cloud_sql_sqlserver_sqlalchemy_limit]
6664 # Pool size is the maximum number of permanent connections to keep.
6765 pool_size = 5 ,
@@ -70,34 +68,26 @@ def init_tcp_connection_engine():
7068 # The total number of concurrent connections for your application will be
7169 # a total of pool_size and max_overflow.
7270 # [END cloud_sql_sqlserver_sqlalchemy_limit]
73- # [END cloud_sql_server_sqlalchemy_limit]
74- # [START cloud_sql_server_sqlalchemy_backoff]
7571 # [START cloud_sql_sqlserver_sqlalchemy_backoff]
7672 # SQLAlchemy automatically uses delays between failed connection attempts,
7773 # but provides no arguments for configuration.
7874 # [END cloud_sql_sqlserver_sqlalchemy_backoff]
79- # [END cloud_sql_server_sqlalchemy_backoff]
80- # [START cloud_sql_server_sqlalchemy_timeout]
8175 # [START cloud_sql_sqlserver_sqlalchemy_timeout]
8276 # 'pool_timeout' is the maximum number of seconds to wait when retrieving a
8377 # new connection from the pool. After the specified amount of time, an
8478 # exception will be thrown.
8579 pool_timeout = 30 , # 30 seconds
8680 # [END cloud_sql_sqlserver_sqlalchemy_timeout]
87- # [END cloud_sql_server_sqlalchemy_timeout]
88- # [START cloud_sql_server_sqlalchemy_lifetime]
8981 # [START cloud_sql_sqlserver_sqlalchemy_lifetime]
9082 # 'pool_recycle' is the maximum number of seconds a connection can persist.
9183 # Connections that live longer than the specified amount of time will be
9284 # reestablished
9385 pool_recycle = 1800 , # 30 minutes
9486 # [END cloud_sql_sqlserver_sqlalchemy_lifetime]
95- # [END cloud_sql_server_sqlalchemy_lifetime]
9687 echo = True # debug
9788 # [END_EXCLUDE]
9889 )
9990 # [END cloud_sql_sqlserver_sqlalchemy_create_tcp]
100- # [END cloud_sql_server_sqlalchemy_create_tcp]
10191
10292 return pool
10393
@@ -157,7 +147,6 @@ def save_vote():
157147 logger .warning (team )
158148 return Response (response = "Invalid team specified." , status = 400 )
159149
160- # [START cloud_sql_server_sqlalchemy_connection]
161150 # [START cloud_sql_sqlserver_sqlalchemy_connection]
162151 # Preparing a statement before hand can help protect against injections.
163152 stmt = sqlalchemy .text (
@@ -181,7 +170,6 @@ def save_vote():
181170 )
182171 # [END_EXCLUDE]
183172 # [END cloud_sql_sqlserver_sqlalchemy_connection]
184- # [END cloud_sql_server_sqlalchemy_connection]
185173
186174 return Response (
187175 status = 200 ,
0 commit comments