[Nitro] OG vs some other ORM packages

Kirk Haines wyhaines at gmail.com
Sun Aug 26 10:12:02 EDT 2007

On 8/25/07, Mark Van De Vyver <mvyver at gmail.com> wrote:

> Kansas (DBI)

Kansas is my baby.  It's been around for a long time and is basically
quite stable.  It uses DBI for the underlying db connectivity instead
of reinventing the wheel there.

It takes the approach of creating Ruby classes that correspond to
database tables, and it tries to be fairly lightweight.  The code is
not particularly large.

It uses Ruby syntax to describe queries:

sodiums = dbh.select(:Chemicals) {|c| c.name =~ '%sodium%'}
critical_issues = dbh.select(:Roofs) {|r| r.sort_by(r.severity =>
'DESC'); r.severity > 3}

It has transaction support that is not dependent on the database
layer.  Queries can return results in normal ruby types such as an
Array or Hash instead of the db-coupled Kansas result types.  The
db-coupled objects can also be marked as read-only, so that changes to
them do not get propagated back to the db.  It supports creating
relationships between tables, for conveniences like:

school = dbh.select(:Schools) {|s| s.name = school_we_are_looking_for }.first
school_cyanides = school.inventory.select {|i| i.name =~ /cyanide/}
art_inventory = school.departments.select {|d| d.name == 'Art'}.chemicals

That's a basic high level view.  I have used it on dozens and dozens
of sites over the years, and it just works.  I have a small community
of users, and insufficient documentation, but it is in daily, active
use, if not daily, active development.

Kirk Haines

More information about the Nitro-general mailing list