Combining Django Pools and Time Fields

Has anyone got a connection pool working with Django, SQLAlchemy and MySQL?

I used this tutorial ( http://node.to/wordpress/2008/09/30/another-database-connection-pool-solution-for-django-mysql/ ), which worked fine, but the problem I am facing , - this is when I return the time field it is converted to timedelta, since the conversions specific to Django are not used.

Conversion code from django / db / backends / mysql / base.py

django_conversions = conversions.copy() django_conversions.update({ FIELD_TYPE.TIME: util.typecast_time, FIELD_TYPE.DECIMAL: util.typecast_decimal, FIELD_TYPE.NEWDECIMAL: util.typecast_decimal, 

})

Connection code from the article:

 if settings.DATABASE_HOST.startswith('/'): self.connection = Database.connect(port=kwargs['port'], unix_socket=kwargs['unix_socket'], user=kwargs['user'], db=kwargs['db'], passwd=kwargs['passwd'], use_unicode=kwargs['use_unicode'], charset='utf8') else: self.connection = Database.connect(host=kwargs['host'], port=kwargs['port'], user=kwargs['user'], db=kwargs['db'], passwd=kwargs['passwd'], use_unicode=kwargs['use_unicode'], charset='utf8') 
+6
django mysql connection-pooling sqlalchemy
source share
1 answer

In the Django trunk, edit django / db / init .py and comment out the line:

signals.request_finished.connect (close_connection)

This signal handler makes it disconnect from the database after each request. I do not know what side effects will do this, but it does not make sense to start a new connection after each request; it destroys performance, as you noticed.

Another necessary change is django / middleware / transaction.py; remove the two tests transaction.is_dirty () and always call commit () or rollback (). Otherwise, it will not commit the transaction if it only reads from the database, which will close the locks that should be closed.

+1
source share

All Articles