Skip to content

Connecting to Informix

Michael Kleehammer edited this page Nov 29, 2026 · 1 revision

These notes apply to the IBM Informix ODBC driver (from the Informix Client SDK) and the HCL OneDB ODBC driver on Linux and other Unix-like systems, used with unixODBC.

Set UNICODE=UCS-2 in odbc.ini

On Unix, the Informix drivers use 4-byte SQLWCHAR characters (UCS-4) by default. unixODBC and pyodbc use 2-byte characters (UTF-16). pyodbc 5 calls the Unicode ("W") ODBC functions, so with this mismatch the driver and pyodbc read each other's text wrongly. The symptoms include:

  • a connect that fails with a truncated error, such as pyodbc.Error: ('H000', '[H000] [ (-11060) (SQLDriverConnect)') (#1433, #1392)
  • the process aborting with *** stack smashing detected *** during the connect or the first query (#1412)

The fix is to tell the driver to use 2-byte characters. Add UNICODE=UCS-2 to the [ODBC] section of the odbc.ini file the driver reads ($ODBCINI, or $HOME/.odbc.ini):

[ODBC]
UNICODE=UCS-2

The [ODBC] section holds settings for the driver itself, not for any one data source, so add it alongside your DSN sections rather than inside one of them.

The same problem occurs without pyodbc, which helps to rule pyodbc in or out. unixODBC's isql uses the ANSI functions and usually works, but iusql uses the Unicode functions and fails the same way pyodbc does until UNICODE=UCS-2 is set.

VARCHAR vs. LONGVARCHAR parameters

Informix needs VARCHAR values sent as SQL_VARCHAR and TEXT values as SQL_LONGVARCHAR. pyodbc handles this by using SQLGetTypeInfo to find the maximum VARCHAR size; see Binding Parameters.

fast_executemany

fast_executemany has been reported to crash with the Informix driver; see fast_executemany support for various ODBC drivers.

Clone this wiki locally