Re: "Naked" typecast functions?
"Karsten Hilbert" <[email protected]> Wed, 21 Apr 2010 22:58:19 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
> psycopg2.NUMBER("12.34", None)
>
> note that the second argument ought to be a cursor but you can safely
> pass None to almost all the typecasters except for the UNICODE one
> because it needs some information about the encoding of the string and
> will try to get it from cursor.connection.
Should UNICODE() then get a third, optional, keyword argument using
which you can, if you want to, pass in an encoding ? In case you don't
and it being the default None psycopg2 will still try getting it from
cursor.connection:
def UNICODE(value, cursor, encoding=None):
if encoding is None:
encoding = cursor.connection.encoding
...
Agreed, the use case is rather slim.
Karsten
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01