[DB-SIG] Type code mappings

M.-A. Lemburg mal at egenix.com
Mon Jan 5 12:48:35 EST 2004


[Switching thread subject]

Since there seems interest in discussing the introduction of
better type code mapping in the DB API, let's start looking
at it...

Here's what we have (type_code refers to the .description
entry; type object to what the DB API 2.0 spec defines as
such):

The DB API 2.0 currently only deals with the problem of letting
the database module figure out an intended binding type of
a parameter by providing factory functions which return objects
with the right type signature for the intended type, e.g.
you can wrap a binary data string into Binary(string) to let
the module bind that particular column as binary data instead
of text data.

On the output side, the support for type mappings is almost
non-existent. The DB API 2.0 only provides means to tell
which group of types a particular output column is member
of, e.g. whether a string return value refers to binary
data (type_code == BINARY) or text data (type_code == STRING).

This is a list of requirements that the new spec should
provide:

a. factory functions to map input objects to objects known and
    supported by the database module (DB API 2.0 already
    defines a few of these, but they should be extended
    to include more fine grained support for numbers, etc.)

b. per-cursor based support for output type mapping, to e.g.
    have the database module return DATETIME columns as
    Python datetime objects, or convert DECIMAL columns
    to mx.Number rational numbers, etc.

c. a standard output type mapping that allow round-trip
    safety, so that passing the output from a query as input
    for an INSERT will not lose information

d. a way to map type_code information to factory functions
    (note: not type object to factory function, since type
    objects often cover more than one type_code)

The bazar is open :-)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 05 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::



More information about the DB-SIG mailing list