DBrb

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.

Examples

  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:
          row["last"]
  end

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.

Obtaining

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

Documentation

RDoc documentation for the library can be browsed here.

Tests

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.

TODO

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:

License

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

Comment on this page: