[cx-oracle-users] Types used for values returned from a query
Brought to you by:
atuining
From: Paul M. <p.f...@gm...> - 2005-02-09 18:00:19
|
I have an application which needs to be able to execute a (relatively) arbitrary query and dump the output to stdout, in such a way that another (non-Python) program can pick up the values and rebuild them exactly. I don't need to support exotic types like LOBs, but I *do* need to handle basic numbers, dates, and strings. To do this, I need to understand *exactly* what types are returned by cursor.fetchone(). Strings and dates are OK - strings are obviously trivial, and dates/timestamps come back as Python datetime values, so I can convert to something transportable like "microseconds since the epoch, converted to a string". But I seem to be having problems with numbers. At the moment, I'm just doing str() on the returned value, and getting odd results. I suspect this is because I'm sometimes getting floats or longs and just doing str() on these is (a) giving me variable formats, and (b) losing precision in the case of floats. Is there a way of getting a precise value back for a numeric field, or is the data lost? Can I do things with NumberVar types, and get the full precision data from that? Alternatively, is there any likelihood of cxOracle using Python 2.4's Decimal type in the near future? Thanks, Paul. |