[PEAK] bulletins example OF DOOM

Phillip J. Eby pje at telecommunity.com
Mon Apr 12 09:40:44 EDT 2004

At 08:25 PM 4/9/04 -0400, Stephen Waterbury wrote:
>Phillip J. Eby wrote:
>>... it's an issue with the DBAPI module, as you can see below:
>>>AttributeError: 'module' object has no attribute 'DATE'
>>Check the 'supportedTypes' list you've defined (or inherited).  It seems 
>>you've subclassed from a connection type for a Postgres driver with a 
>>'DATE' type, but the driver you're using either doesn't support it, or 
>>calls it something else.  (Welcome to the wonderful world of Python DBAPI 
>I went back and changed 'DATE' in my
>(which I had copied from PsycopgConnection)
>to 'Date' (as it's spelled in the DBAPI spec), and
>sure enough, I got a different traceback.
>Progress ... :)

No, you don't have progress.  'Date' is not a DBAPI type constant.  By 
convention, they're all-uppercase like NUMBER, TIMESTAMP, etc.  Look in 
your DBAPI module for *only* such constants, and make sure your 
supportedTypes list matches.

The second thing you need to do is verify whether your DBAPI module uses a 
'values' attribute on its type objects (such as INTEGER), in which case you 
may need to redefine the 'typeMap' method to handle type objects 
differently.  In the worst case, you can simply do this:

typeMap = binding.Make(dict)

to disable all type conversion for your driver.  The typeMap is supposed to 
be a dictionary of DBAPI type objects (i.e. values that can appear in a 
cursor's 'description' attribute) containing application-specific type 
conversion functions.  This is used to give you some database independence 
as well as convenient conversion to your app's data types.  For example, 
one will often want to convert DB-specific timestamp types to Python's 
datetime type.

More information about the PEAK mailing list