Re: "Naked" typecast functions?

Federico Di Gregorio <fog-NGVKUo/i/[email protected]> Wed, 21 Apr 2010 22:39:21 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 21/04/2010 17:28, Peter Sabaini wrote:
> Is it possible to use the various typecasting functions of psycopg2 in a
> non-implicit manner? AFAICT the typecasters get called automatically
> depending on the parameters passed in to .execute(). Can I call those
> typecasters without a cursor object? 

You can; just invoke the type object as in

psycopg2.NUMBER("12.34", None)

note that the second argument ought to be a cursor but you can safetly
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.

federico

-- 
Federico Di Gregorio                                       fog-NGVKUo/i/[email protected]
                      Sei una bergogna. Vergonga. Vergogna. -- Valentina

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 262 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvPYoIACgkQvcCgrgZGjevYsACdHE/0QSypTRh78lBejm8cqqUB
eewAoM7icTP30jfObiepYFUTwxdN+pXn
=vLzp
-----END PGP SIGNATURE-----