Re: psycopg2 adaptation for UUIDs

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno lun, 22/09/2008 alle 14.29 +0200, Brian Sutherland ha scritto:
> On Fri, Sep 19, 2008 at 09:27:47PM +0200, Federico Di Gregorio wrote:
> > Il giorno mar, 16/09/2008 alle 10.51 +0200, Brian Sutherland ha scritto:
> > > Seeing as both PostgreSQL 8.3 and python 2.5 support the UUID data type,
> > > I thought it might be a good feature if psycopg2 supported them natively
> > > as well. (don't know what project policy is on this)
> > > 
> > > This is the code I am using to be able to put UUID object into and get
> > > them out of PostgreSQL:
> > 
> > Starting from your code I added UUID support in psycopg2 (pushed to bzr
> > trunk right now). Just:
> > 
> > import psycopg2.extras
> > psycopg2.extras.register_uuid()
> > 
> > Note that register_uuid() takes an optional OID parameter for
> > non-standard installations where the OID value of the PosgreSQL uuid
> > type is not 2950. register_uuid() will raise an exception if Python uuid
> > module is not available.
> 
> Thanks a lot!
> 
> Er, but also, I found a bug in my code (that ended up in your patch).
> Below is a patch showing it and my solution (which is probably not
> exactly correct).

Ops! Yes.I should add NULL checks to all tests. Thank you vey much for
the patch.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
                              Viviamo in un mondo reale, Ciccio. -- Lucy

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkjYlbUACgkQvcCgrgZGjeua5gCgoBYUODpriUUl3fhsmb6sRusl
5eIAn36tOOm+RG9d7YFpOZbVIUYVjNej
=51ye
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.