Installation guide
6. mxODBC Connection Objects
The method returns a tuple
(integer, string) giving an integer decoding
(in native integer byte order) of the first bytes of the API's result as well as the
raw buffer data as string. It is up to the caller to decode the data (e.g. using the
struct module).
This API gives you a very wide range of information about the underlying
database and its capabilities. See the ODBC SQLGetInfo API Documentation
for
more information.
.nativesql(command)
This method returns the command as it would have been modified by the driver
to pass to the database engine. It is a direct interface to the ODBC API
SQLNativeSql().
In many cases it simply returns the
command string unchanged. Some drivers
unescape ODBC escape sequences in the command string. Syntax checking is
usually not applied by this method and errors are only raised in case of
command string truncation.
Not all mxODBC subpackages support this API.
.rollback()
In case the database connection has transactions enabled, this method causes
the database to roll back any changes to the start of the current transaction.
Closing a connection without committing the changes first will cause an
implicit rollback to be performed.
This method is only available if the ODBC driver database subpackage was
compiled with transaction support. For ODBC manager subpackages it is
always available, but may raise a NotSupportedError in case the connection
does not support transactions.
.setconnectoption(option, value)
This method lets you set some ODBC integer options to new values, e.g. to set
the transaction isolation level or to turn on auto-commit.
option must be an integer. Suitable option values are available through the
SQL object, e.g. SQL.ATTR_AUTOCOMMIT corresponds to the SQL option
SQL_ATTR_AUTOCOMMIT in C (see the Constants section 10.5 for details).
The method is a direct interface to the ODBC
SQLSetConnectOption()
function. Please refer to the ODBC Documentation for more information.
Note that while the API function also supports setting character fields, the
method currently does not know how to handle these.
Note for ADABAS/SAP DB/MAX DB users:
Adabas, SAP DB and MAX DB can emulate several different SQL dialects. They
have introduced an option for this to be set. These are the values you can use:
1 = ADABAS, 2 = DB2, 3 = ANSI, 4 = ORACLE, 5 = SAPR3. The option code
is
SQL.CONNECT_OPT_DRVR_START + 2 according to the Adabas
documentation. Please consult your driver documentation for details.
93