On Jul 13, 2008, at 5:00 PM, Eric Lemoine wrote:

>
> On Fri, Jul 11, 2008 at 9:45 AM, Eric Lemoine <[EMAIL PROTECTED]>  
> wrote:
>> Hello
>>
>> When using autoload the created Numeric columns have asdecimal set to
>> True (I use postgres, dunno if it's different with other databases).
>> If would like that they have asdecimal set to False. Can I force that
>> without having to override the results of the autoload with explicit
>> Numeric(asdecimal=False) columns in my Table object?
>>
>> Thanks a lot,
>
> Sorry for insisting a bit. Does anyone know if it's possible to use
> autoload=True and have numeric column values represented as floats
> rather than decimal.Decimal's (asdecimal=False)?

Hi....for this behavior, options include:

- monkeypatch the dialect to return the Float type instead of the  
Decimal type, by modifying the dialect's ischema_names dict.   
Unfortunately there's not yet a standard API for this, and while most  
dialects have this dict at the module level, others have it at class  
level.  So this is a pretty hacky solution that might even break when  
the dialect refactor is merged.

- after the Table is reflected, loop through every column, check for  
isinstance(column.type, Numeric), set the "asdecimal" flag to false.   
Simplistic but effective.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to