beyma
1
Hello,
I work with a local mysql sqlite file, for which I successfully establish connection using
connection = st.connection('mydb', type='sql')
I’d like to specify the parameter pool_size
. I thought I could use
connection = st.connection('mydb', type='sql',
connect_args=dict(pool_size=100)
)
but when performing a query I get:
TypeError: 'pool_size' is an invalid keyword argument for Connection()
How can I specify the pool_size
parameter in this case ?
1 Like
beyma
2
any feedback would be strongly appreciated
Hi, @beyma . I faced the same problem and solved in this way:
from typing import TypeVar
from streamlit.connections import SQLConnection
_T = TypeVar("_T", bound=SQLConnection)
def db_client() -> type[_T]:
""" Returns the database client connection. """
client = st.connection(
"oracle",
type=SQLConnection,
ttl=0,
autocommit=True,
pool_size=0,
max_overflow=20,
pool_timeout=60,
pool_recycle=300,
pool_pre_ping=True
)
return client
I hope this can be useful for you.
beyma
4
Dear Thiago,
thanks a lot for your input ! I’ll give it a try to see if my recurrent disconnections to a mysql database got improved.
Thanks again !
system
Closed
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.