[Psycopg] Decimal data types

Federico Di Gregorio fog at initd.org
Thu Sep 15 09:38:08 CEST 2005


Il giorno mer, 14/09/2005 alle 13.20 -0500, Michael Hipp ha scritto:
> In pyPgSQL I had to convert float variables to a type of PgNumeric in order to 
> save them in a PostgreSQL field like "decimal(11,2)".

You can pass a float value or a Decimal. Note that by when passing a
float there can be (and will be) rounding errors.

PostgreSQL decimal and numeric types are automatically converted to
Python Decimals (when available).

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
                           Don't dream it. Be it. -- Dr. Frank'n'further
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.initd.org/pipermail/psycopg/attachments/20050915/0dddd68a/attachment.pgp


More information about the Psycopg mailing list