Adrian wrote: > I am trying to change the default column type mapping in sqlalchemy. > Analogous to the description in the MySQLdb User's Guide (http://mysql- > python.sourceforge.net/MySQLdb.html) I tried the following. > > from MySQLdb.constants import FIELD_TYPE > my_conv = { FIELD_TYPE.DECIMAL: float } > ENGINE = create_engine( 'mysql://%s:[EMAIL PROTECTED]:3306/%s', > connect_args = > {'conv': my_conv} ) > > This works if I use MySQLdb directly but not with sqlalchemy. I > suspect the syntax I used is wrong. It will create an engine and > connection but as soon as a query is issued a TypeError is raised. Is > there an error in my connect_args dictionary or do I have to change > the mapping behaviour somewhere else?
Try modifying a full MySQLdb.converters.conversions.copy() with the float conversion instead of that sparse mapping. SA uses bind params exclusively for input so you're seeing a conversion failure sooner than you might with MySQLdb directly. Try something like this: cr = cx.cursor() cr.execute("SELECT %s, %s", [10.2, 'quux']) cr.fetchall() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---