Installation guide
mxODBC - Python ODBC Database Interface
Python Type SQL Type Comments
(signed long) driver/manager, so expect the usual
truncations.
Long Integer SQL.CHAR
(char *)
Conversion from the Python long integer is
done via the string representation since there
usually is no C type with enough precision to
hold the value.
Float SQL.DOUBLE
(double)
Conversion from the Python float (a C double)
to the SQL column type is left to the ODBC
driver/manager, so expect the usual
truncations.
decimal.Decimal SQL.VARCHAR,
SQL.LONGVARCHAR
(
char *)
Conversion from a Python decimal.Decimal
instance is done via the string representation to
avoid losing precision.
The long variant is used for decimal
representations longer than 256 characters.
DateTime SQL.TIMESTAMP
or
SQL.DATE
Converts the DateTime instance into a
TIMESTAMP or DATE struct defined by the
ODBC standard.
The ODBC driver may use the time part of the
instance or not depending on the SQL column
type (DATE or TIMESTAMP).
Seconds are rounded according to the setting
of the .timestampresolution setting, which
defines the resolution of the timestamps in
nanoseconds.
mxODBC will round the timestamp's second
value to the nearest nanosecond fraction
defined by this setting in order to avoid issues
with float second values which sometimes
cannot be represented with full accuracy. If not
set, the .timestampresolution attribute defaults
to 1 nanosecond, so rounding usually is done
to the nearest nanosecond, which is also the
smallest fraction supported by the ODBC
standard.
DateTimeDelta SQL.TIME Converts the DateTimeDelta instance into a
TIME struct defined by the ODBC standard.
Fractions of a second will be lost in this
conversion.
datetime.date SQL.DATE
Converts the datetime.date instance into a
DATE struct defined by the ODBC standard.
Note that some database backends don't
support date column types and give an error
when using datetime.date objects. MS SQL
Server 2000 and 2005 are examples. MS SQL
148