Skip to content
This repository

Ruby bindings for the SQLite3 embedded database

Merge branch '1-3-stable'

* 1-3-stable: (25 commits)
  Backport: Add installation command for Debian/Ubuntu
  Doc: update repository links
  Backport: Correct gem license
  Update Manifest for new files
  Prepare for release
  Backport: Update Travis-CI information
  Update ChangeLog with backports
  Backport: Removed unused pointer
  Update ChangeLog with merge backports
  Backport: convert from test/unit to minitest
  Backport gem cross-compilation changes
  Backport: Reset before CHECKing the status
  Adjust CHANGELOG with merge commits
  Backport: Add MIT license reference to gemspec.
  Improve test for #65 to prove that the blob is passed into the function correctly
  Add test for calling function with blob argument (#65). Also, improve testing of blob storage in general, utilizing Blob type to correct column affinity.
  Resolve bug #65. Correctly convert blob values to ruby
  Now prepare for release
  Use newer rake-compiler
  Unset environment variables during cross compilation

latest commit b73fae5a4c
Aaron Patterson tenderlove authored
Octocat-spinner-32 ext Merge branch 'master' into nobu-unused-variables February 24, 2014
Octocat-spinner-32 faq Add missing `I` August 10, 2013
Octocat-spinner-32 lib Merge branch '1-3-stable' February 25, 2014
Octocat-spinner-32 tasks Fix mini ports compilation issue February 25, 2014
Octocat-spinner-32 test Fix for new unique constraint message of SQLite 3.8.2 in test December 12, 2013
Octocat-spinner-32 .gemtest Add missing .gemtest July 25, 2011
Octocat-spinner-32 .gitignore Backport gem cross-compilation changes August 17, 2013
Octocat-spinner-32 .travis.yml Backport: Update Travis-CI information August 17, 2013
Octocat-spinner-32 API_CHANGES.rdoc adding change to api notes August 25, 2010
Octocat-spinner-32 CHANGELOG.rdoc Merge branch '1-3-stable' February 25, 2014
Octocat-spinner-32 ChangeLog.cvs ChangeLog is dynamically generated again. February 15, 2005
Octocat-spinner-32 Gemfile Backport gem cross-compilation changes August 17, 2013
Octocat-spinner-32 LICENSE use a more recent email address May 02, 2008
Octocat-spinner-32 Manifest.txt Update Manifest for new files August 17, 2013
Octocat-spinner-32 README.rdoc Doc: update repository links August 19, 2013
Octocat-spinner-32 Rakefile Relocate gem definition to its own task. March 03, 2010
Octocat-spinner-32 setup.rb Change Config to RbConfig and remove unused vars June 30, 2013

SQLite3/Ruby Interface


This module allows Ruby programs to interface with the SQLite3 database engine ( You must have the SQLite engine installed in order to build this module.

Note that this module is only compatible with SQLite 3.6.16 or newer.


require "sqlite3"

# Open a database
db = "test.db"

# Create a database
rows = db.execute <<-SQL
  create table numbers (
    name varchar(30),
    val int

# Execute a few inserts
  "one" => 1,
  "two" => 2,
}.each do |pair|
  db.execute "insert into numbers values ( ?, ? )", pair

# Execute inserts with parameter markers
db.execute("INSERT INTO students (name, email, grade, blog) 
            VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])

# Find a few rows
db.execute( "select * from numbers" ) do |row|
  p row

Compilation and Installation

Install SQLite3, enabling the option SQLITE_ENABLE_COLUMN_METADATA (see for details).

Then do the following:

ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Alternatively, you can download and install the RubyGem package for SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first):

gem install sqlite3

If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing:

gem install sqlite3 -- --with-sqlite3-include=/opt/local/include \


OMG! Something has gone wrong! Where do I get help?

The best place to get help is from the sqlite3-ruby mailing list which can be found here:


I've found a bug! Where do I file it?

Uh oh. After contacting the mailing list, you've found that you've actually discovered a bug. You can file the bug at the github issues page which can be found here:



For help figuring out the SQLite3/Ruby interface, check out the SYNOPSIS as well as the RDoc. It includes examples of usage. If you have any questions that you feel should be address in the FAQ, please send them to the mailing list

Source Code

The source repository is accessible via git:

git clone git://
Something went wrong with that request. Please try again.