469,582 Members | 2,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,582 developers. It's quick & easy.

ADODB Currency type broken in Python win32?

It looks to me like the handling of the currency type in an ADODB
connecction from Python is broken. Currency data in an Access database is
stored as a 64-bit integer, scaled by 10000. In an ADODB recordset, this
is returned as a 2-tuple, where the second element is the currency value,
but the value is stored as a normal integer, not a lont integer. Thus, it
fails for values greater than about $214,700 (2**32 / 10**4).

Here is an example:

import win32com.client
conn = win32com.client.Dispatch("ADODB.Connection")
conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=anydatabase.mdb")
cmd = win32com.client.Dispatch("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT CCur(250000) AS myMoney;"
rs = cmd.Execute()[0]
for f in rs.Fields:
print f.Name
print f.Type
print f.Value

One would expect

(0, 2500000000L)

Instead, we get:

(0, -1794967296)

The value has wrapped at 2**31.
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 19 '05 #1
0 1109

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.