[cx-oracle-users] Re: SDO_GEOMETRY data type
Brought to you by:
atuining
From: Jani T. <re...@lu...> - 2005-07-06 17:01:29
|
Mikel Larreategi kirjoitti: > Mikel Larreategi wrote: > >> >>> import cx_Oracle as db >> >>> con = cb.connect('user', 'mysecretpassword') >> >>> cur = con.cursor() >> >>> cur.execute('select a.GEOM_WGS84.GET_WKT(), a.id_postal from >> n_edifgen_3d a where id_postal between 10000 and 10005') >> [<CLOBVar object at 0x40167930>, <NumberVar object at 0x4016a0b0>] >> >>> cur.description >> [('A.GEOM_WGS84.GET_WKT()', <type 'CLOBVar'>, -1, 4000, 0, 0, 1), >> ('ID_POSTAL', <type 'NumberVar'>, 127, 22, 0, -127, 1)] >> >>> b = cur.fetchone() >> >>> b >> (<ExternalLobVar object at 0x40162060>, 10000.0) >> >>> b[0].read() >> 'POINT (-2.35566829112215 43.2908549259473)' > > > I can also get the info in this way: > > >>> cur.execute('select a.geom_wgs84.sdo_point.X, > a.geom_wgs84.sdo_point.Y from n_edifgen_3d a where id_postal between > 10000 and 10005') > [<NumberVar object at 0x4016a140>, <NumberVar object at 0x4016a188>] > >>> cur.fetchone() > (-2.35566829112215, 43.290854925947293) Sure it works that way, at least for points. But WKT works for almost anykind of shapes - points, shapes, linestrings, geometry collections. With CLOB's you have to remember to read var in temporary structure in python if you need to work with multiple values, otherwise that externallobvar is not valid after next fetchone(). And best of that is you can really insert WKT back to Oracle. -- Jani Tiainen |