Mike Slinn

Database Frameworks for Sinatra

Published 2023-02-01. Last modified 2023-02-22.
Time to read: 3 minutes.

This page is part of the ruby collection.

I want to build a web project using Ruby, Sinatra and a database. Ruby on Rails is not an appropriate web framework for my project, but Sinatra seems about right. Choosing a database layer, however, has proven problematic.

At first, I found code examples for Sinatra with DataMapper. I liked DataMapper a lot. The documentation was well done. The code examples worked or could easily be made to work. Many examples can be found.

Then I learned that DataMapper had been abandoned 12 years ago in favor of Ruby Object Mapper (ROM). The last DataMapper version was v1.2.0, released on October 13, 2011.

Second System Effect

Supposedly, ROM was originally going to be DataMapper version 2, but actually, ROM is a entirely different user experience. This seems to be a classic example of the second system effect.

Worse, the syntax continues to change so much that older ROM projects no longer work; even recent project fail for this reason. I could not find information about upgrading projects for any version upgrade.

ROM has very few learning resources; for example, there are no books on ROM. None of the few example projects I could find work anymore – if they ever did.

Then the coup de grĂ¢ce: StackOverflow queries to date:

ROM seems like a failed project. Too bad. Technically, it looks good. Unless significant resources were applied to overcome the issues I mention, however, I think that using ROM on a project would be an unnecessary liability.

Two Contenders

The two most popular contenders for a Sinatra ORM are ActiveRecord (best known because it was developed for use in Ruby on Rails), and Sequel. I found the following comparison infographic on the Hanami Mastery website. I am not really interested in Hanami, since it competes with Sinatra.

Sinatra ActiveRecord

Using ActiveRecord with Sinatra is a common design choice. The GitHub project for sinatra-activerecord was originally written by Blake Mizerany, the author of Sinatra. The project ships with two complete demonstration projects, one for sqlite and one for postgres.

I wrote up my experience with sinatra-activerecord separately.

Sequel for Sinatra

Sequel is another popular ORM for Ruby and Sinatra. I was impressed by the excellent documentation in the README. User-centric product exposition is so rare in F/OSS!

About the Author

I, Mike Slinn, have been working with Ruby for a long time now. Back in 2005, I was the product marketing manager at CodeGear (the company was formerly known as Borland) for their 3rd Rail IDE. 3rd Rail supported Ruby and Ruby on Rails at launch.

In 2006, I co-chaired the Silicon Valley Ruby Conference on behalf of the SD Forum in Silicon Valley. As you can see, I have the t-shirt. I was the sole chairman of the 2007 Silicon Valley Ruby Conference.

Several court cases have come my way over the years in my capacity as a software expert witness. The court cases featured questions about IP misappropriation for Ruby on Rails programs. You can read about my experience as a software expert if that interests you.

I currently enjoy writing Jekyll plugins in Ruby for this website and others, as well as Ruby utilities.



* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.