This post originated from an RSS feed registered with Ruby Buzz
by Anders Bengtsson.
Original Post: Missing: Self-Contained Database
Feed Title: A View From Above: Ruby
Feed URL: http://www.ghostganz.com/blog/xml/rss20/category/Ruby/feed.xml
Feed Description: Anders Bengtsson on programming and other things
I was going to use ActiveRecord for some simple storage in a small application I’m hacking on. Since ActiveRecord itself has support for lots of databases I figured that it didn’t matter which database I used for testing1.
In Java I would have used Hypersonic, or some other self-contained in-memory database, for this. Looking around in Rails land, you find that most people use Rails’ testing features and run their tests against a separate instance of their production database, usually MySQL. Other people use Sqlite3, which seems to be the simplest database around.
Since I don’t have a production database (and generally dislike MySQL2), I looked at Sqlite. First of all, it requires Sqlite itself to be installed. In OS X this is already done, but it will be a problem elsewhere. Then there’s a confusing selection of different gems with drivers. But once you get the right one installed, it seems to work fine.
Once I started working with it, I ran into a problem. Every time something is wrong with the database structure, no matter if it’s the whole database missing or just a single column misspelled, I get the same error:
Since I was changing the database structure a lot, I got this all the time. Don’t know if this is Sqlite, the driver, ActiveRecord or me that’s to blame, but it wasn’t very practical.
Since my patience is very short, I simply dropped the database storage feature from my app. :) But there seems to be two issues here:
There is no self-contained, gem-installed database for Ruby
The error handling in Sqlite, or something on the way to Sqlite, isn’t very good
I now hope that someone will tell me what an idiot I am and that I should use some other driver, or some other database.
1 I’m using RSpec, which is the best testing framework since sliced bread.