You can provide parameterized queries in a sequence or in the argument list: You can use fetchall, fetchone, and fetchmany to retrieve Rows returned from SELECT statements:Ĭnxn = nnect('DSN=CData Informix Source User=MyUser Password=MyPassword')Ĭursor.execute("SELECT Id, Price FROM Books WHERE Category = 'US'") Instantiate a Cursor and use the execute method of the Cursor class to execute any SQL statement. Below is the syntax for a connection string:Ĭnxn = nnect('DRIVER= Server=10.0.1.2 Port=50000 User=admin Password=admin Database=test ')Ĭnxn = nnect('DSN=CData Informix Sys ') You can now connect with an ODBC connection string or a DSN.
You can use the pip utility to install the module: pip install pyodbcīe sure to import with the module with the following: import pyodbc Connect to IBM Informix Data in Python You can follow the procedure below to install pyodbc and start accessing IBM Informix through Python objects.
Password: Set this to the password of a user allowed to access the database.ĭriver = CData ODBC Driver for IBM Informixįor specific information on using these configuration files, please refer to the help documentation (installed and found online).
User: Set this to the username of a user allowed to access the database.Database: Set this to the name of the IBM Informix database.Port: Set this to the port the IBM Informix server is listening on.Server: Set this to the name of the server running IBM Informix.Set the following properties to connect to IBM Informix Additionally, you can create user-specific DSNs that will not require root access to modify in $HOME/.odbc.ini. You can modify the DSN by editing the system data sources file (/etc/odbc.ini) and defining the required connection properties. The driver installation predefines a system DSN. To do so, edit the INI file for the driver (), which can be found in the lib folder in the installation location (typically /opt/cdata/cdata-odbc-driver-for-informix), as follows: To use the CData ODBC Driver for IBM Informix with unixODBC, ensure that the driver is configured to use UTF-16.
Once the driver is installed, you can list the registered drivers and defined data sources using the unixODBC driver manager: List the Registered Driver(s) rpms, run the following command with sudo or as root: Tools or applications that support ODBC connectivity.įor Debian-based systems like Ubuntu, run the following command with sudo or as root:įor Red Hat systems and other systems that support. The driver installer registers the driver with unixODBC and creates a system DSN, which can be used later in any Once you have downloaded the file, you can install the driver from the terminal.
You can download the driver in standard package formats: the Debian. USER DATA SOURCES.: /home/myuser/.odbc.ini Below is an example of the output of this command:įILE DATA SOURCES.: /etc/ODBCDataSources User data sources can only be accessed by the user account whose home folder the odbc.ini is located in. The output of the command will display the locations of the configuration files for ODBC data sources and registered ODBCĭrivers. You can determine the location of the configuration files on your system by entering the following command into a The unixODBC driver manager reads information about drivers from an odbcinst.ini file and about data sources from an odbc.iniįile. $ sudo yum install unixODBC unixODBC-devel $ sudo apt-get install unixODBC unixODBC-devįor systems based on Red Hat Linux, you can install unixODBC with yum or dnf: For this article, you will use unixODBC, a free and open source ODBC driver manager that is widely supported.įor Debian-based systems like Ubuntu, you can install unixODBC with the APT package manager:
For more information on the supported versions of Linux operating systems and the required libraries, please refer to the "Getting Started" section in the help documentation (installed and found online).īefore installing the driver, check that your system has a driver manager. There are also several libraries and packages that are required, many of which may be installed by default, depending on your system.
The CData ODBC Drivers are supported in various Red Hat-based and Debian-based systems, including Ubuntu, Debian, RHEL, CentOS, and Fedora. Using the CData ODBC Drivers on a UNIX/Linux Machine
This article shows how to use the pyodbc built-in functions to connect to IBM Informix data, execute queries, and output the results. With the CData Linux/UNIX ODBC Driver for IBM Informix and the pyodbc module, you can easily build IBM Informix-connected Python applications. The rich ecosystem of Python modules lets you get to work quicker and integrate your systems more effectively.