views:

676

answers:

0

Has anyone got connection pooling 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 great but the issue I'm having is whenever I bring back a time field it is being converted to a timedelta since the Django-specific conversions are not being 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 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')