Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created May 17, 2012 22:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save practicingruby/2722101 to your computer and use it in GitHub Desktop.
Save practicingruby/2722101 to your computer and use it in GitHub Desktop.
require "sqlite3"
SQLite3::Database.new(":memory:") do |db|
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment