[python-sybase] Decoding DataBuf objects?

Skip Montanaro skip at pobox.com
Thu, 27 May 2004 17:32:12 -0500


I have a parameter dictionary filled in after a callproc() call:

    >>> params
    {'@e_year': <DataBufType object at 0x8138598>, '@e_month': <DataBufType object at 0x81384d0>, '@symbol': 'ZB', '@simulation_date': '20040527'}
    >>> yr = params['@e_year']
    >>> dir(yr)
    ['count', 'datatype', 'format', 'maxlength', 'name', 'precision', 'scale', 'status', 'strip', 'usertype']
    >>> yr.count
    1
    >>> yr.datatype
    8
    >>> yr.format
    0
    >>> yr.maxlength
    4
    >>> yr.name
    '@e_year'
    >>> yr.precision
    0
    >>> yr.scale
    0
    >>> yr.status
    1024
    >>> yr.strip
    0
    >>> yr.usertype
    0
    >>> yr[0]
    2
    >>> yr[1]
    0
    >>> yr[2]
    IndexError: buffer index out of range
    >>> len(yr)
    1
    >>> int(yr)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    TypeError: int() argument must be a string or a number

but can't tell how to actually get the real value out of it.  The actual
value for the '@e_year' parameter is supposed to be 104.  I don't see it
anywhere obvious.  The description of DataBuf objects in the docs doesn't
seem to jive with what I have.

-- 
Skip Montanaro
Got gigs? http://www.musi-cal.com/submit.html
Got spam? http://www.spambayes.org/
skip@pobox.com