Re: psycopg2 adaptation for UUIDs

ibu ☉ <ibu-qs259T/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization http://ibu.radempa.de
Message-ID <[email protected]>
Well, I should try things out before writing enthusiastically.

For empty arrays split creates a non-empty list contianing one empty 
string...

UUID_ = psycopg2.extensions.new_type((2951,), "UUID[]",
        lambda s, cursor: [uuid.UUID(i) for i in s[1:-1].split(',') if 
len(i)>0])
psycopg2.extensions.register_type(UUID_)


Dated 2009-08-29 11:43 , ibu ☉ <[email protected]> said:
> Of course, str() is superfluous.
>> import uuid
>> UUID_ = psycopg2.extensions.new_type((2951,), "UUID[]",
>>        lambda s, cursor: [uuid.UUID(i) for i in 
>> str(s[1:-1]).split(',')])
>> psycopg2.extensions.register_type(UUID_)
>>

_______________________________________________
Psycopg mailing list
[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
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.