Skip to content
Ruby bindings for the SQLite3 embedded database
Ruby C
Branch: master
Clone or download
Latest commit 6fc5073 Jan 8, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Add GitHub Actions for Windows CI Dec 20, 2019
ext/sqlite3 Fix Ruby 2.7 rb_check_safe_obj warnings Dec 18, 2019
lib Bumping version Dec 18, 2019
rakelib Add GitHub Actions for Windows CI Dec 20, 2019
test The taint mechanism will be deprecated in Ruby 2.7 Nov 21, 2019
.gemtest Add missing .gemtest Jul 25, 2011
.travis.yml .travis.yml - fix RubyGems update code Dec 20, 2019
API_CHANGES.rdoc adding change to api notes Aug 25, 2010
Gemfile Fix hoe issue in Gemfile Dec 19, 2019
LICENSE use a more recent email address May 3, 2008
Manifest.txt Aggregators backed by ruby arrays, no xDestroy callback Mar 29, 2017
README.rdoc readme fix Nov 23, 2016
Rakefile moving tasks to rakelib Jan 31, 2017
setup.rb Change Config to RbConfig and remove unused vars Jun 30, 2013
sqlite3.gemspec Add a gemspec file via hoe-gemspec Mar 26, 2018


SQLite3/Ruby Interface

Build Status


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 table
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

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

# Create another table with multiple columns

db.execute <<-SQL
  create table students (
    name varchar(50),
    email varchar(50),
    grade varchar(5),
    blog varchar(50)

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

db.execute( "select * from students" ) 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 addressed in the FAQ, please send them to the mailing list

Source Code

The source repository is accessible via git:

git clone git://
You can’t perform that action at this time.