Ruby/Informix – Ruby library for connecting to IBM Informix.


The situation that started it all [link].


The latest version of Ruby/Informix can be found at:

Supported platforms

Ruby/Informix has been tested succesfully with Informix 7 and above, and Informix CSDK 2.81 and above, on the following platforms:

Operating System     Architecture
Solaris              SPARC64      
Mac OS X             x86-64
GNU/Linux            x86, x86-64
Windows XP/2000      x86
HP-UX 11.11          PA-RISC 2.0 64-bit

Send me an e-mail if you have [un]succesfully tested Ruby/Informix on another platform.



  • Informix CSDK 2.81 or above

If you want to build Ruby/Informix instead of installing a precompiled gem, you will also need:

  • Microsoft Visual Studio 6.0, for Windows or

  • an ANSI C compiler, for UNIX and Linux

Rubygem installation

gem install ruby-informix


RDoc and ri documentation is automatically installed. It can also be found online at:


Connecting to a database

db = Informix.connect('stores')

Traversing a table

db.each('select * from stock') do |r|
  # do something with the record

Fetching all records from a table

records = db.cursor('select * from stock') do |cur|

Inserting records

stmt = db.prepare('insert into state values(?, ?)')
stmt.execute('CA', 'California')'NM', 'New Mexico')
stmt['TX', 'Texas']

Iterating over a table using a hash (shortcut)

db.each_hash('select * from customers') do |cust|
  puts "#{cust['firstname']} #{cust['lastname']}"

More examples can be found at:

Data types supported

Informix                          Ruby
SMALLINT, INT, INT8, FLOAT,      Numeric
DATE                             Date
DATETIME                         Time
INTERVAL                         Informix::IntervalYTM, Informix::IntervalDTS
DECIMAL, MONEY                   BigDecimal
BOOL                             TrueClass, FalseClass
BYTE, TEXT                       StringIO, String
CLOB, BLOB                       Informix::Slob

NULL values can be inserted and are retrieved as nil.

Any IO-like object that provides a read method, e.g. StringIO or File objects, can be used to insert data in BYTE or TEXT fields. Data retrieved from BYTE and TEXT fields are stored in String objects.

Strings can be used where Informix accepts them for non-character data types, like DATE, DATETIME, INTERVAL, BOOL, DECIMAL and MONEY


  • Use blocks to release Informix resources automatically as soon as possible. Alternatively, use #free.

  • You can optimize cursor execution by changing the size of fetch and insert buffers, setting the environment variable FET_BUF_SIZE to up to 32767.


Feel free to send me bug reports, feature requests, comments, patches or questions directly to my mailbox or the following forums:

  • Online forums at Rubyforge [link]

  • Mailing list [link]

Presentations and articles about Ruby/Informix

  • “Talking with Perl, PHP, Python, Ruby to IDS” [link], Eric Herber, The Informix Zone.

  • “Informix on Rails” [link], Guy Bowerman, IBM developerWorks Blogs: Informix Application Development.

  • “Ruby/Informix, and the Ruby Common client” [link], Guy Bowerman, IBM developerWorks Blogs: Informix Application Development.

  • “Using IBM Informix Dynamic Server on Microsoft Windows, Part 6” [link], Akmal B. Chaudhri, IBM developerWorks: On demand demos.


Ruby/Informix is available under the three-clause BSD license

:include: COPYRIGHT