[DB-SIG] How to connect to informix DB in an easy way

James Briggs jimmy.briggs at gmail.com
Tue Aug 25 02:04:04 CEST 2009


I have had success in connecting to almost any database using the pyodbc
module:

    http://code.google.com/p/pyodbc/

The difficult part is finding the correct connection string - see
http://www.connectionstrings.com/informix

I haven't connected to an Informix database myself, but have connected to
everything from Access, SQL Server to DB2 on Series i.
For some of these an ODBC driver will eed to be installed on your PC (unless
one is already provided by Microsoft).
The driver name can be found in the ODBC administration part of the Windows
control panel when you add a new ODBC DSN.

For Example:
Access_connect-str = 'Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\mydatabase.mdb;Uid=me;Pwd=pass'
MSSQL_connect_str = 'DRIVER={SQL
Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass'
iSeries_connect_str = 'DRIVER={iSeries access ODBC
Driver};SYSTEM=10.3.36.123;UID=me;PWD=pass'

For Informix using microsoft's .net driver -
connect_str='Provider=Ifxoledbc;Data Source=dbName at serverName;User ID=
myUsername;Password=myPassword;'

Using a connection string such as one of the ones above a connection is
created as follows
           db=pyodbc.connect(connect_str)

If you can define an ODBC data source (through windows ODBC administration
tool) a connection can be created with:
           db=pyodbc.connect('DSN=%s;UID=%s;PWD=%s' %
(myDSN,myUsername,myPassword))

Goodluck.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20090825/7d803950/attachment.htm>


More information about the DB-SIG mailing list