2

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?

4

1 回答 1

3

据此: http ://dev.mysql.com/doc/connector-python/en/connector-python-connection-pooling.html

您可以只调用池的 close() 方法

编辑 :

正如所评论的,这不会关闭池,它只会将连接返回到池。

我查看了这个源代码https://github.com/mysql/mysql-connector-python/blob/master/lib/mysql/connector/pooling.py

看起来唯一可以做到的方法是 _remove_connections 但它是用于测试的。

于 2015-09-06T08:51:39.433 回答