New To Connection Pooling
So I am new to connection pooling. I am trying to determine how to use a pool in order to speed up my query. I have a query that works, but I dont think I am using the pool corre
Solution 1:
Your question didn't make it clear how cursor
comes from db
.
Consider using sqlalchemy. Then you get automatic pooling for free.
import pandas as pd
import sqlalchemy as sa
engine = sa.create_engine(your_local_mysql_url_with_credentials)
with engine.connect() ascon:
df1 = pd.read_sql(query1, con)
df2 = pd.read_sql(query2, con)
df3 = pd.read_sql(query3, con)
The pool winds up being an attribute of engine
.
In practice you'll seldom care about inspecting it,
since it Just Works, hanging onto a server TCP connection across queries.
Post a Comment for "New To Connection Pooling"