2
votes

I wonder why django doesn't support connection pool? I can't bear open/close connection every request. I try to solve it, but hasn't a good solution.

I try to use mysql_pool, but fail:

TypeError: init() takes exactly 1 argument (3 given) 
2
__init__ expects only 1 argument and you're passing 3, why?shahjapan
Are you running django as CGI (instead of something like as WSGI or mod_python)?Paulo Scardine

2 Answers

11
votes

EDITED: look at Django persistent database connection (feature introduced in 1.6).

Persistent connections avoid the overhead of re-establishing a connection to the database in each request. They’re controlled by the CONN_MAX_AGE parameter which defines the maximum lifetime of a connection. It can be set independently for each database.

9
votes

Here's a discussion about why django did not add pooling to the core: https://groups.google.com/forum/#!topic/django-developers/NwY9CHM4xpU

Generally speaking it's because third party applications such as pgbouncer do it better.