On Oct 14, 2010, at 1:35 PM, Chris Withers wrote:

> On 14/10/2010 17:10, Michael Bayer wrote:
>> 
>>> I get passed a bunch of sql to execute, I don't have control over that.
>>> Where do I wire in Numeric(as_decimal=False) and how do I tell where I need 
>>> to given an arbitrary select as a string of sql?
>> 
>> text() is in the docs, including an example of typemap:
>> 
>> http://www.sqlalchemy.org/docs/core/expression_api.html?highlight=text#sqlalchemy.sql.expression.text
> 
> Okay, but I don't see how a typemap helps.
> All I'm getting is a string of sql, I don't know what column names are 
> included in that,

If you don't know your columns, neither does SQLAlchemy.    Depending on your 
DBAPI you may be able to get the DBAPI itself to not use the Decimal type, see 
the docs on your DBAPI for information on type coercion at the DBAPI level.

Otherwise, you'd filter your result set, do isinstance(x, Decimal), convert to 
float.  You may be able to use result.cursor.description if the DBAPI returns 
reasonable types.   We could someday add an execution_option() that allows a 
map of DBAPI types mapped to result types to be passed.   

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to