[DB-SIG] Type code mappings: expanding the type objects

M.-A. Lemburg mal at egenix.com
Tue Jan 6 05:51:42 EST 2004


Federico Di Gregorio wrote:
> Il lun, 2004-01-05 alle 18:48, M.-A. Lemburg ha scritto:
> [snip]
> 
>>The bazar is open :-)
> 
> 
> let's start with a _very_ small change, i.e., augmenting the number of
> type objects. i think we can do that in an absolutely backward
> compatible way. instead of having a flat set of type objects let's order
> them by placing the old ones at the first level of a tree and the others
> on the second level, as leaves:
> 
> STRING
> |__CHAR
> |__VARCHAR
> |__TEXT
> BINARY
> NUMBER
> |__INTEGER
> |__LONGINTEGER
> |__FLOAT
> |__COMPLEX
> DATETIME
> |__TIME
> |__DATE
> |__TIMESTAMP
> |__INTERVAL
> ROWID
> 
> and require that is a type object matches a type code, the same type
> code is matched by the parent(s) too. this allows for expanding the
> types without requiring any modification of old code, because if, for
> example, the type code for an int4 matches INTEGER it will always (as in
> DBAPI-2.0) also match NUMBER.

Good idea.

> the list is just preliminary and open to suggestions. i suppose we can
> have more string types (unicode anyone?), different binaries, times with
> tz information and such.

In mxODBC I'm passing through the SQL type code integers for the
columns in .description. This allows for all supported types
being reported.

Currently these are:

    BIGINT
    BINARY
    BIT
    CHAR
    DATE
    DECIMAL
    DOUBLE
    FLOAT
    INTEGER
    LONGVARBINARY
    LONGVARCHAR
    NUMERIC
    REAL
    SMALLINT
    TIME
    TIMESTAMP
    VARBINARY
    VARCHAR
    WCHAR
    WCHAR_LONGVARCHAR
    WCHAR_VARCHAR

plus a few more exotic ones that are ODBC cruft. The WCHAR ones
are Unicode string columns.

Most of these are SQL92 names for the types, perhaps we should
stick to them ?!

> the trick here is to let the modules implement extra type objects (like
> geometic types in postgresql) but mandate a wide enough base to satisfy
> everybody.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 06 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