Installation guide
8. Data Types supported by mxODBC
SQL Type Python Type Comments
SQL.INTEGER,
SQL.BIT
converted to a Python integer the ODBC driver/manager, so expect
the usual truncations.
SQL.BIGINT
Long integer or
any other object which can be
converted to a Python long
integer
Conversion to and from the Python
long integer is done directly, if
possible, or via the string
representation if the C data types are
not sufficient to hold the numeric
data.
If mxODBC has to use the string
representation for interfacing, you
may receive errors indicating
truncation or errors because the
database sent string data that cannot
be converted to a Python long
integer.
Not all SQL databases implement
this type or impose size limits.
SQL.DECIMAL,
SQL.NUMERIC
Python decimal.Decimal or
Float or
any other object which can be
converted to a Python float
Conversion from the Python float (a
C double) to the SQL type is left to
the ODBC driver/manager, so expect
the usual truncations.
Python decimals are passed to that
database as strings, so no truncation
or loss of precision occurs.
SQL.REAL,
SQL.FLOAT,
SQL.DOUBLE
Float or
any other object which can be
converted to a Python float
Conversion from the Python float (a
C double) to the SQL type is left to
the ODBC driver/manager, so expect
the usual truncations.
SQL.DATE
DateTime instance or
datetime.date instance or
a tuple
(year,month,day) or
String/Unicode or
a ticks value as Python
number
While you should use DateTime
instances, the module also accepts
Python datetime.date instances,
ticks (Python numbers indicating the
number of seconds since the Unix
Epoch; these are converted to local
time and then stored in the database)
and tuples (year,month,day) on
input.
SQL.TIME
DateTimeDelta instance or
datetime.time instance or
a tuple
(hour,minute,second) or
String/Unicode or
a tocks value as Python
number
While you should use DateTimeDelta
instances, the module also accepts
Python datetime.time instances,
tocks (Python numbers indicating the
number of seconds since 0:00:00.00)
and tuples
(hour,minute,second) on
input.
Seconds are rounded to the nearest
nanosecond in order to avoid issues
145