Hooking Up the Database

We’ve put off implementing the database layer for as long as we could. But with the rest of the surrounding layers defined, it’s all that’s left.

Getting to Know Sequel

For this exercise, you’re going to use a Ruby database library called Sequel. Sequel allows you to create tables, add data, and so on, without tying your code to any specific database product. You’ll still need to choose a database, though, and for this project the low-maintenance SQLite library will do fine.[40]

Go ahead and add the following two lines to your Gemfile:

 gem ​'sequel'​, ​'4.48.0'
 gem ​'sqlite3'​, ​'1.3.13'

Now, rerun Bundler to install the new libraries:

 $ ​​bundle install
 Fetching ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.