[python-sybase] How to force a different datetime output?

Skip Montanaro skip at pobox.com
Thu, 27 May 2004 14:34:35 -0500


I'm trying to get the Object Craft Sybase module used at work instead of a
homegrown hack.  Based upon a lot of use of the homegrown module, one
requirement is that dates be represented as floating point seconds since the
Unix epoch.  It appears that Sybase returns some sort of DateTime object.
Given a DateTime object, d, both int(d) and float(d) fail for me with this
sort of message:

    >>> float(d)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/home/titan/skipm/local/lib/python2.3/site-packages/Sybase.py", line 154, in _cslib_cb
        raise Error(_fmt_client(msg))
    Error: Layer: 2, Origin: 1
    cs_convert: cslib user api layer: external error: Conversion between 12 and 10 datatypes is not supported.

Can I cleanly get from a DateTime object to a float or do I have to inject a
new version of _column_value() into Sybase.py?  ('Twould be nice if there
was a standard way to establish type converters on a per-connection basis.)

Thanks,

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