ADODB Currency type broken in Python win32?

T

Tim Roberts

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

myMoney
6
(0, 2500000000L)

Instead, we get:

myMoney
6
(0, -1794967296)

The value has wrapped at 2**31.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top