2

I've looked through stackoverflow and can see some oldish posts on this and wondered what the current thinking is about pooling connections in Python for MySQL.

We have a set of python processes that are threading with each thread creating a connection to MySQL. This all works fine, but we can have over 150 connections to MySQL.

When I look at the process state in MySQL I can see that most of the connections are asleep most of the time. The application is connecting to a Twitter streaming API so its busy but this only accounts for a few connections.

Is there a good way of adding connection pooling to Python MySQL and can this be done simply without re-writing all of the existing code?

Many thanks.

PT

1
  • If you decide you want to re-write code, SQLAlchemy handles this effectively (sqlalchemy.org) Commented Nov 29, 2011 at 9:22

1 Answer 1

1

See DBUtils

Maybe you have an abstract layer for MySQL, you can modify this layer to avoid rewriting all the code.

If not, you have to hack your Python-MySQL driver.

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

Comments

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.