DBrb is a wrapper to facilitate working with Ruby DBI. The intention is to make the most commonly used DB functionality (as determined by me) easy and intuitive to use.


  db = DBrb.new("my_dbi_driver_string", "usr", "credentials")

  # return single value or array if a single row is selected
  i = db.sql("select max(id) from some_table")
  n, l =  db.sql("SELECT first, last FROM some_name WHERE id = ?", 1000)

should the two examples above return more than one row, the first one is used.

  db.sql("SELECT first, last FROM some_name WHERE id < ?", 1000) do |row|
          puts "#{row.first} #{row.last}"
          # in case of conflicts with existing methods, you can use:

The row that the sql iterates over is the standard DBI::Row, which has been supplemented with accessor methods named after the columns in case these don't conflict with existing methods.


You can download the current release here as a tgz archive or here as a Ruby gem.


RDoc documentation for the library can be browsed here.


I've currently tested DBrb with the following databases:

Since even these two have already brought some minor inconsitancies in the behaviour of the database driver implementations to light, I would assume that some adjustments might need to be made to use the library with other databases.


Inconsitancies between Mysql and Postgres Drivers

This list is for me to remember some of the issues I came across, if it turns out to be useful to anyone else, all the better:


DBrb is Copyright (c) 2006 by Tim Becker (tim@kuriositaet.de) and is released under the same license as Ruby.

Comment on this page: