[python-win32] ODBC dates and buffers

Mark Hammond mhammond at skippinet.com.au
Tue Nov 11 07:24:27 CET 2008


The 'odbc' module has always had its own 'date' object - an object with a
'value' attribute holding a integer which is supposed to be compatible with
the time module.  It predates the datetime module by many years.

As part of the py3k work Roger has been doing, he dropped the custom types
from the (dbi) module, so datetime and buffer objects are used directly - we
have decided it is reasonable that when people are porting to py3k they
examine their use of the custom date objects and convert them to use
datetime objects.  This is also the approach we will probably take with the
pywintypes PyTime object in py3k (ie, drop it completely), but that is a
digression for now - this message is just about the odbc and dbi modules.

In py2k, the ideal thing would be for us to invent a "forwards
compatibility" mechanism for this module - existing code can continue to
work but a transition plan could be put in place, somewhat similarly to how
pythoncom is doing the 'currency' changes.  However, best I can tell, the
date support in the odbc module is so broken as to render it unusable - eg,
in Feb 2007, Robin Becker pointed out this fact on this mailing list and a
suggested workaround was to use strings to manipulate the date fields!
Further, my attempts to get the (old) odbc test suite passing with date
objects is failing, which is further evidence to me of its broken-ness.
Similar broken-ness exists when using blob/binary fields, which Roger
addressed in py3k by switching them to native objects too.

My question is: will breaking the support for these types actually
inconvenience anyone?  To put it another way, is anyone aware of real apps
that successfully use the odbc module to work with dates in a database?  If
not, I won't bother trying to invent a transition plan and "just do it" (as
Roger advocates - and indeed the trunk already has!)

[My gut feeling is that we can break odbc dates without hurting anyone, but
we will need a transition plan for the pywintypes PyTime object in py2k -
but that is for another day...]

Thanks,

Mark





More information about the python-win32 mailing list