ADODB Currency type broken in Python win32?

Discussion in 'Python' started by Tim Roberts, Apr 27, 2005.

  1. Tim Roberts

    Tim Roberts Guest

    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.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Apr 27, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vikas Yadav
    Replies:
    0
    Views:
    1,146
    Vikas Yadav
    Sep 9, 2003
  2. dcrespo
    Replies:
    1
    Views:
    473
    infidel
    Oct 28, 2005
  3. Steven D'Aprano

    Why are "broken iterators" broken?

    Steven D'Aprano, Sep 21, 2008, in forum: Python
    Replies:
    8
    Views:
    683
  4. Cameron Simpson

    Re: Why are "broken iterators" broken?

    Cameron Simpson, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    607
    Cameron Simpson
    Sep 22, 2008
  5. Fredrik Lundh

    Re: Why are "broken iterators" broken?

    Fredrik Lundh, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    622
    Fredrik Lundh
    Sep 22, 2008
Loading...

Share This Page