Problem with dbi, odbc module and Oracle 9.2 - suffixed "L" with number data type

Andrew MacIntyre andymac at bullseye.apana.org.au
Thu Mar 2 23:16:17 CET 2006


[posted & mailed]

dananrg at yahoo.com wrote:

> The only issue I've had so far is retrieving data from Oracle when an
> integer has been defined like:
> 
>        number(p)    [same thing as number(p,0) evidently]
> 
> This is from a database I didn't design and can't change. Evidently
> there are new ways to declare integer data types in Oracle.
> 
> The problem is that the ODBC module suffixes an "L" to any integer
> returned that
> was defined as data type number(p). For example, an integer stored as:
> 56  will be returned as 56L. Actually, it now seems to be doing the
> same thing, at least in some cases, for number data types declared as
> number(p,s). What gives? Anyone know why this would happen?

The 'L' suffix indicates a Python long, which is an arbitrary precision
integer.  If you're confident that the number in question is in the
normal integer range, you can coerce it to a normal int with int(p) so
the formatting on display doesn't include the suffix - if the number
is too large to coerce an OverflowError will be raised (for 2.2 and
earlier at least; 2.4 and later unify ints and longs).

> Can't use mxODBC because it's a commercial product and can't use
> cx_oracle at the moment because I am stuck with Python 2.1 (for ESRI
> geoprocessing), and there is no cx_oracle for Python 2.1 (starts with
> Python 2.2 and refuses to install for 2.1). I could install a later
> version of Python independently, but I need to be able to do the
> geoprocessing that 2.1 allows as well as ODBC calls to Oracle all in
> the same script. This means dbi,odbc seems to be my only choice.

If you have access to a compiler, you may be able to build cx_Oracle
for Python 2.1, but you would have to check that the code doesn't 
require  Python 2.2 or later features.  The MingW gcc package should 
work with
Python 2.1 (which was built with VC6 as I recall).

I've been bugging ESRI about upgrading, and I'm sure others have too.

-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia



More information about the Python-list mailing list