Created
May 17, 2012 22:43
-
-
Save practicingruby/2722101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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