简体   繁体   中英

Ending a connection pool in mysql-connector-python

I have a connection pool that I create using mysql-connector-python:

dbconfig = {
        "database": db,
        "user":     "user"
}    
cnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = appname,
                                  pool_size = 5,
                                  **dbconfig)

In the mysql-connector API , there doesn't appear to be a method for ending a connection pool. Is there a way to end a connection pool?

According to this: http://dev.mysql.com/doc/connector-python/en/connector-python-connection-pooling.html

You can just call the close() method of the pool

EDIT :

As commented, this will not close the pool, it will only return the connection to the pool.

I looked at this source code https://github.com/mysql/mysql-connector-python/blob/master/lib/mysql/connector/pooling.py

And it looks like the only method that will do it is _remove_connections but it is intended for testing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM