5

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

3 Comments

According to the docs, that method is for returning an individual connection to the pool. It doesn't look like that method can be called on a pool. Am I wrong?
It says "mostly for testing", but looks like it will accomplish what I want. I will test it to make sure.
The GitHub link is dead. Here's a live one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.