Strange Symphonies The whole is greater than the sum of its parts

2May/072

Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Ubuntu Feisty Fawn

SQLite is good for development and testing, and depending on your needs production even. By default Typo uses SQLite for production. The greatest advantage is that it's light. (like duh), and very easy to deploy.

Note: There are two versions of SQLite, version 2 and 3. They produce databases which are incompatible with each other.

Version 2

Enter into the Terminal:


sudo apt-get install ruby1.8-dev libsqlite0-dev
sudo gem install sqlite-ruby

If you see this, select 1 (enter it in).


Select which gem to install for your platform (i486-linux)
1. sqlite-ruby 2.2.3 (ruby)
2. sqlite-ruby 2.2.3 (mswin32)
3. sqlite-ruby 2.2.2 (ruby)
4. sqlite-ruby 2.2.2 (mswin32)
5. Skip this gem
6. Cancel installation
>

Edit the file [image16x16:file] RAILS_ROOT/config/database.yml. For now we are using the [image16x16:database] development environment. The environment you are deploying your database should look like so.

development:
  adapter: sqlite
  dbfile: db/development.sql

Version 3

Enter into the Terminal:


sudo apt-get install ruby1.8-dev libsqlite3-dev
sudo gem install sqlite3-ruby

If you see this, select 1 (enter it in).


Select which gem to install for your platform (i486-linux)
1. sqlite3-ruby 1.2.1 (ruby)
2. sqlite3-ruby 1.2.1 (mswin32)
3. sqlite3-ruby 1.2.0 (mswin32)
4. sqlite3-ruby 1.2.0 (ruby)
5. Skip this gem
6. Cancel installation
>

Edit the file File RAILS_ROOT/config/database.yml. For now we are using the Database development environment. The environment you are deploying your database should look like so.

development:
  adapter: sqlite3
  dbfile: db/development.sql

Conclusion

There you have it, your database is now set up!

Related posts

Tags

Comments (2) Trackbacks (0)
  1. Hi Aiz,

    Didnt work for me. I installed ruby1.9-dev and libsqlite0-dev…

    Select which gem to install for your platform (i486-linux)
    1. sqlite-ruby 2.2.3 (ruby)
    …….
    5. Skip this gem
    6. Cancel installation
    > 1
    Building native extensions. This could take a while…
    ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

    ruby extconf.rb install sqlite-ruby
    extconf.rb:1:in `require’: no such file to load — mkmf (LoadError)
    from extconf.rb:1

    Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3 for inspection.
    Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/ext/gem_make.out

  2. me too…
    I’m using Fedora8, with sqlite3.4 and get a
    1. sqlite-ruby 2.2.3 (ruby)
    2. sqlite-ruby 2.2.3 (mswin32)
    3. sqlite-ruby 2.2.2 (ruby)
    4. sqlite-ruby 2.2.2 (mswin32)
    5. Skip this gem
    6. Cancel installation

    and fail with same error output.


Leave a comment


No trackbacks yet.