Friday, November 1, 2013

Installing SQLite3 on Ubuntu/Xubuntu 13.04

1. Installing SQLite3
$ sudo apt-get install sqlite3
Test the installation.
$ mkdir sqlprj
cd sqlprj/
$ sqlite3 test.db
SQLite version 2013-01-09 11:53:05
sqlite> .exit

2. Installing sqliteman (GUI app to manage SQLite)
sudo apt-get install sqliteman
Test the installation by launching it from menu and creating a table and inserting a few rows.

3. Installing ruby gem for SQLite3 
$ sudo apt-get install libsqlite3-dev
$ sudo gem install sqlite3
Test the installation.
# test.rb
# based on samples in 

require 'sqlite3'

    db = "test.db"
    stm = db.prepare "SELECT * FROM party" 
    rs = stm.execute 
    rs.each do |row|
        puts row.join "\s"
rescue SQLite3::Exception => e 
    puts "Exception occured"
    puts e
    stm.close if stm
    db.close if db    
$ ruby test.rb
1 Doe, John per
2 Big Company org