Installation guide

8. Data Types supported by mxODBC
8.4 Python Type Input Binding
The following mappings are used for input variables in Python type input binding
mode -
cursor.bindmethod (inherited from connection.bindmethod) set to
BIND_USING_PYTHONTYPE. The table shows how the different Python types are
converted to SQL types.
Python Type SQL Type Comments
String SQL.VARCHAR,
SQL.LONGVARCHAR,
SQL.VARBINARY,
SQL.LONGVARBINARY
(char *)
The conversion truncates the string at the SQL
field length. If the string contains binary data,
SQL.VARBINARY is used for passing the data to
the ODBC driver/manager.
The long variants are used for strings longer
than 256 characters.
Unicode SQL.WVARCHAR,
SQL.WLONGVARCHAR
(wchar_t *)
The conversion truncates the string at the SQL
field length. Note that not all ODBC
drivers/managers support Unicode data at C
level.
This binding is used for all cursors which do
not have the
.stringformat attribute set
to
EIGHTBIT_STRINGFORMAT or
UNICODE_STRINGFORMAT.
In
EIGHTBIT_STRINGFORMAT mode
(default) and
UNICODE_STRINGFORMAT
mode, Unicode objects are converted to a 8-bit
strings first and then passed to the ODBC
driver/manager.
The long variant is used for Unicode data
longer than 256 code points.
buffer or
memoryview
SQL.VARBINARY,
SQL.LONGVARBINARY
(char *)
The conversion truncates the string at the SQL
field length. The string may contain binary
data.
If the ODBC driver/manager doesn't support
processing binary data using strings, wrap the
data object using Python buffers (via the
buffer() constructor) or Python memory
views (via the
memoryview()constructor)
to have mxODBC use a binary SQL type for
interfacing to the driver/manager. The Oracle
ODBC drivers usually need this.
The long variant is used for binary data longer
than 256 bytes.
Integer SQL.SLONG Conversion from the signed long to the SQL
column type is left to the ODBC
147