FAQ
On Windows 2000, using Oracle and Active State's Python 2.1, and
mxODBC module, the result returned by the cursor object's fetchall
function contains floating point numbers for columns defined as
"NUMBER" datatype. This column containing integers only.

For example, the following code:

import mx.ODBC.Windows, pprint
db = mx.ODBC.Windows.connect(dsn, user, password)
cursor = db.cursor()
cursor.execute('select * from entity_type')
results = cursor.fetchall()
pprint.pprint(results)

returns a result set as follows:

[(1.0, 'ADSERVER'),
(2.0, 'LOGMANAGER'),
(3.0, 'PUSHERSYNC'),
(4.0, 'PUSHER'),
(5.0, 'DERIVE'),
(6.0, 'MEDIASERVER')]

At the same time, similar code using ODBC modules that came with
Active State's Python 2.1:

import odbc, dbi, pprint
db = odbc.odbc('%s/%s/%s' % (dsn, user, password))
cursor = db.cursor()
cursor.execute('select * from entity_type')
results = cursor.fetchall()
pprint.pprint(results)

returned the expected result set:

[(1L, 'ADSERVER'),
(2L, 'LOGMANAGER'),
(3L, 'PUSHERSYNC'),
(4L, 'PUSHER'),
(5L, 'DERIVE'),
(6L, 'MEDIASERVER')]

This does not seem right. Am I misunderstanding something here?
TIA

Search Discussions

  • David Bolen at Jun 14, 2001 at 10:56 pm

    victor at prodigy.net (Victor Muslin) writes:

    On Windows 2000, using Oracle and Active State's Python 2.1, and
    mxODBC module, the result returned by the cursor object's fetchall
    function contains floating point numbers for columns defined as
    "NUMBER" datatype. This column containing integers only.
    Well, although the database column may only have integer values, the
    NUMBER datatype can be defined to hold just about anything from
    integer to double precision floating point. So one question would be
    how is the actual column defined, and not just what does it contain.

    Perhaps mxODBC is interrogating the server more completely and
    discovering that the column is actually defined to support floating
    point precision, and is setting the returned data type appropriately.

    --
    -- David
    --
    /-----------------------------------------------------------------------\
    \ David Bolen \ E-mail: db3l at fitlinxx.com /
    FitLinxx, Inc. \ Phone: (203) 708-5192 |
    / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
    \-----------------------------------------------------------------------/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 14, '01 at 9:22p
activeJun 14, '01 at 10:56p
posts2
users2
websitepython.org

2 users in discussion

David Bolen: 1 post Victor Muslin: 1 post

People

Translate

site design / logo © 2022 Grokbase