can someone explain me how can we handle the situation when the max connections limit has been reached for any database. Can we make a connection in wait state until any existing connection gets released automatically.
import snowflake.connector as sf
import sqlalchemy.pool as pool
def get_conn():
conn = sf.connect(
user='username',
password='password',
account='snowflake-account-name',
warehouse='compute_wh',
database='customer_data'
)
return conn
mypool = pool.QueuePool(get_conn, max_overflow=10, pool_size=5)
a = mypool.connect()
a1 = mypool.connect()
a2 = mypool.connect()
a3 = mypool.connect()
a4 = mypool.connect()
a5 = mypool.connect()
a6 = mypool.connect()
a7 = mypool.connect()
a8 = mypool.connect()
a9 = mypool.connect()
a11 = mypool.connect()
a12 = mypool.connect()
a13 = mypool.connect()
a14 = mypool.connect()
a15 = mypool.connect()
till a14 we will get 10 connections objects successfully but when we uncomment and run this a15. we will get an error as pool exhausted.. how to handle this case ??
if we need to write the logic in such a way that we have to give access even
though the instances keep increasing. help me how i can send back the connection
to the pool ??