Re: Arrays of composite types
Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | initd.org |
| Message-ID | <1243595516.18616.15.camel@erin> |
Il giorno mer, 27/05/2009 alle 16.44 -0400, Jacob Joseph ha scritto: > Hi all. > > I have a few questions about the use of psycopg for dealing with > arrays of such composite types. I have a few composite types in > postgres, each of a few floats and integers. I've then constructed an > array of such types. > > I'd like to be able to get back a list of tuples. Currently, > registering the composite type doesn't end up running my adapter, > presumably because the composite array actually has a different OID. > I can register the array OID as well, but then I'm left splitting and > parsing the entire string in python. Is there a way to use the > existing array parsing code in psycopg2, and use the newly registered > adapter on each element? Right now it is not possible. I'll have a look at the code and see if the parsing stuff can be made generic enough to be exported at the Python level. > As for parsing composite types, is there any loss of precision > converting the string representation of a (e.g.,) float from the > database to a python float? Is the original bit representation of the > float available for use? Right now psycopg uses the textual representation sent by PostgreSQL, not the binary one. But there should be no loss of precision unless the conversion function does something wrong. > For a final bit of wishful thinking, are there plans to automatically > derive adapters for composite types. Are there fundamental obstacles > to this? It depends on how much information about the composite types can be made available to psycopg. Anyway, sincerely, I better like to have composite types implemented as special classes in Python with custom conversion functions (like GeoTypes does). You have to write a little bit more code but then you have much more control over the results. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer [email protected] INIT.D Developer fog-NGVKUo/i/[email protected] The number of the beast: vi vi vi. -- Delexa Jones _______________________________________________ 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) iEYEABECAAYFAkofwvwACgkQvcCgrgZGjetIogCgkTQvlTZNnUolE1Bjv9xjxqdy tBMAoNM4x1DKhVrJcz4E50AYWGi/+l2N =TaSY -----END PGP SIGNATURE-----