Setting up SQLite3 for Ruby on Rails Development

UPDATE: Thanks to an astute reader, it seems to have full SQLite3 support on Windows you need to add the SQLite3.dll and the SQLite3.def files also in your path.  I put these in my ruby/bin folder, which is where they will be in the Instant Rails release coming up.

The release of Ruby on Rails 2.0.2 made some fairly significant changes in the default database for Rails applications.  The default, and standard, database has always been MySql but the Rails team felt it easier for development to use SQLite3 and make it the new default.

Setting up SQLite3 is pretty straight forward both on Windows and the Mac OSX, both Tiger and Leopard come with SQLite3 already installed so that makes the Mac one up on Windows.  My Tiger installation had SQLite3 v3.13 installed on it so I wanted to make sure I had the latest at the time of this writing and put 3.5.4 on it.

Installing on Windows

The installation on Windows was really straight forward.  The main thing is to download the pre-compiled version of SQLite3 3.5.4 from the SQLite web site, unzip it and copy the single sqlite3.exe to my ruby/bin directory.

Now that SQLite3 is installed, just install the gem:

gem install sqlite3-ruby

And that’s it.

Installing/Updating on the Apple Mac OSX

Upgrading my Rails installation was a breeze on my MacBook Pro, after upgrading to RubyGems 1.0 the Rails 2.0.2 install went through without a hitch.  The only real concern I had about upgrading to Rails 2.0.2 on the Mac was the fact the default database for 2.0.2 is SQLite3 and I had an old version.  I feel a bit indifferent about installing over versions of software installed by Apple in the event it is used by something and I break it.  I am pretty new to the Mac and fixing an issue like this can sometimes be intimidating.

I found an older version of SQLite3, here:


There are several ways to update software like this on the Mac and using MacPorts seems to be a popular way to do it, but I chose to install from source.   I have a Source directory in my home folder on my Mac and I simply start everything from there.  So, to install I did the following:

$ curl -O
$ tar xzf sqlite-3.5.4.tar.gz
$ cd sqlite-3.5.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

After working with Windows systems for most of my professional career I chuckle at how cryptic the commands are in Unix-like environments.  Maybe this is to keep the barrier to entry high.

Using the “which sqlite3” command should reveal the same location as the original SQLite3 installation.  If you actually type in “sqlite3” you enter the command mode of SQLite3 and should see the new 3.5.4 version.

The last step to is to install the Ruby driver for SQLite3, accomplished with:

$ sudo gem install sqlite3-ruby

This installed without any problems and was good to go with using SQLite3 on my Mac Rails 2.0.2 installation.  It’s funny though, the Windows installation was very easy and the Mac install took a bit of work that was not particularly obvious.  I thought the Mac was supposed to be so much easier than the PC?  Isn’t this what the Apple ads try to get us to believe?  I guess Apple just has better marketing.

Technorati Tags: ,,,

16 responses to “Setting up SQLite3 for Ruby on Rails Development

  1. Quick note – if you haven’t installed the DLL for windows, you need to do that as well. The sqlite3.exe file alone wasn’t enough for me – I had to download the “” file and unzip the .dll and .def files into C:\Windows\System32. Obviously any directory in your path will do.

  2. @Nerdmaster – strange. I unzipped the sqlite3.exe and run it just fine without any additional dll’s.

    What application were you doing that required the .dll and .def files?

  3. Hello Rob, please don’t bash “Unix-like systems” because you only know about Windows. For starters, compiling a tar-ball this way really is obvious when you have even the smallest amount of experience with the *nix CLI. What’s more, almost all *nix distros have decent package management built in. This would allow you to install sqlite (and automically keep it updated) with a simple command like “apt-get install sqlite3” without any manual searching/downloading required.

  4. @Bosmeeuw – I am not bashing any Unix-like systems. I love working on my Mac and the Linux systems I maintain. I was only pointing out the steps I went through on both and then looked back and realized there was quite a few more steps in the Mac procedures.

    So if what I wrote seemed to bash, not meant to be. It was more like a tongue in check joke on how Mac folks always claim their process is so simple.

  5. Thanks for the helpful article. I chuckled at your ‘chuckle’ line myself, although the number of steps are identical in Linux as in OSX.

    @Bosmeeuw: OSX isn’t *nix, it’s UNIX. Subtle but important difference. There is no package management system for OSX. It’s POSIX, i.e. make; make install. `apt-get` is Debian-based, and while it’s *nix, it’s not UNIX. Of course, real Linux users use Slackware anyway, as you know. 🙂

  6. There are several ways to update software like this on the Mac and using MacPorts seems to be a popular way to do it, but I chose to install from source.

    For future reference, MacPorts builds things from source using a recipe you can control, and merely creates a way to track and manage installed software.

  7. For all the Debian users that can’t live without apt-get, it is available for Mac OS X:

    @Bosmeeuw: OSX isn’t *nix, it’s UNIX. Subtle but important difference. There is no package management system for OSX. It’s POSIX, i.e. make; make install. `apt-get` is Debian-based, and while it’s *nix, it’s not UNIX. Of course, real Linux users use Slackware anyway, as you know.

  8. I’d say UNIX is covered under *nix – spot the wildcard!

    Rob: don’t worry, I’m not defending Mac users here 🙂 But if you do a lot of server administration, you really should look into package management systems. Over time it can become hard to manage your system if you roll everything from source. Package management keeps track of dependencies, updates, etc.

  9. Rob – sqlite3 runs fine; it’s when I try to run rake that the *.dll issue comes up… would be nice to include this with the gem (when getting it for win machines).

    Anyway, manually emptying the sqlitedll*.zip into the ruby/bin area does the trick…

    ah, manual configurations are _so_ much fun! *smirk*


  10. @Yak-man – thanks for the info, I wasn’t sure when the .dll was needed. I hadn’t seen an issues with experimenting with it. I am glad for the info as I put SQLite3 into InstantRails.

  11. @Bosmeeuw and others. What is the “best” way to manage packages on the Mac? I have used MacPorts but didn’t know if that was the standard Mac package management system. I have used some others on Linux but what do most people use? I know it varies based on Linux distribution but I am curious.

  12. Pingback: Handy Patriawan’s Blog » Blog Archive » Rails 2.0.2 Uses SQLite3 by Default?

  13. Pingback: » Flex + Ruby on Rails Installation

  14. Thanks for this, it really helped me. Although this is probably a bit old, but as with Nerdmaster, I also needed to put those dll files in the System32 dir, for the sqlite3 to properly work. Otherwise the rails application doesn’t work, for instance the default //localhost:3000/ page’s “About you application’s environment” link doesn’t work properly, and it comes up with an UNKNOWN ERROR and a full stack trace.

    Thought I would report this, for other newbies experimenting with RoR! A simple but effective guide, thanks!

  15. Ah! I missed out Yak-man’s comment… So there you go it is important to have those dlls!

  16. @Mikey Thanks for updating your experience, all great to know. Yes, I had updated my original post saying the files were needed. At first I wasn’t sure but they are definitely needed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s