Skip to content

haileys/sqlite3-ruby

This branch is 487 commits behind sparklemotion/sqlite3-ruby:main.

Folders and files

NameName
Last commit message
Last commit date
Apr 27, 2023
Mar 2, 2023
Feb 28, 2023
May 16, 2023
Jul 5, 2022
May 24, 2023
Apr 27, 2023
Jul 25, 2011
May 24, 2023
May 24, 2023
Jul 4, 2022
May 16, 2023
Feb 22, 2023
Feb 15, 2005
May 24, 2023
Apr 27, 2023
May 24, 2023
May 3, 2008
Jul 4, 2022
May 24, 2023
Jun 25, 2022
Feb 22, 2023
May 16, 2023
May 24, 2023

Repository files navigation

Ruby Interface for SQLite3

Overview

This library allows Ruby programs to use the SQLite3 database engine (http://www.sqlite.org).

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

Unit tests Native packages

Quick start

For help understanding the SQLite3 Ruby API, please read the FAQ and the full API documentation.

A few key classes whose APIs are often-used are:

  • SQLite3::Database (rdoc)
  • SQLite3::Statement (rdoc)
  • SQLite3::ResultSet (rdoc)

If you have any questions that you feel should be addressed in the FAQ, please send them to the mailing list or open a discussion thread.

require "sqlite3"

# Open a database
db = SQLite3::Database.new "test.db"

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

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

# Find a few rows
db.execute( "select * from numbers" ) do |row|
  p row
end
# => ["one", 1]
#    ["two", 2]

# Create another table with multiple columns
db.execute <<-SQL
  create table students (
    name varchar(50),
    email varchar(50),
    grade varchar(5),
    blog varchar(50)
  );
SQL

# Execute inserts with parameter markers
db.execute("INSERT INTO students (name, email, grade, blog)
            VALUES (?, ?, ?, ?)", ["Jane", "me@janedoe.com", "A", "http://blog.janedoe.com"])

db.execute( "select * from students" ) do |row|
  p row
end
# => ["Jane", "me@janedoe.com", "A", "http://blog.janedoe.com"]

Support

Installation or database extensions

If you're having trouble with installation, please first read INSTALLATION.md.

General help requests

You can ask for help or support:

Bug reports

You can file the bug at the github issues page.

Contributing

See CONTRIBUTING.md.

License

This library is licensed under BSD-3-Clause, see LICENSE.

Dependencies

The source code of sqlite is distributed in the "ruby platform" gem. This code is public domain, see LICENSE-DEPENDENCIES for details.

About

Ruby bindings for the SQLite3 embedded database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 72.9%
  • C 25.7%
  • Shell 1.4%