Thanks for pointing this out. I found out that psycopg 1.1.21 gives
back a Numeric as float. When I switched to psycopg2, a Decimal object
is automatically returned.

I was switching from SQLObjects, and there the Numeric is
automatically converted to Decimal seemingly by SQLObjects, so I took
that for granted. Maybe this should also be added to SA, since then
the application won't be dependant on the return type of the DBAPI
layer?

On 6/3/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
the float type coming from Numeric etc. is straight from the DBAPI,
in this case psycopg2.  If youd like to make your own Decimal type
which translates this value back and forth from whatever float value
psycopg2 is giving you, simply subclass TypeDecorator, specify
Numeric as the 'impl',  and implement the appropriate
convert_bind_param(), convert_result_value() methods.

instructions are here:

        http://www.sqlalchemy.org/docs/types.myt#types_custom

if you get that done, theres no reason it cant be stuck into the
types module, just wouldnt be available if youre on 2.3.

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to