Created
September 1, 2009 17:09
-
-
Save eik3/179231 to your computer and use it in GitHub Desktop.
Ruby <-> SQLite3
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
fn="test.sqlite" | |
exit(1) if File.exist?(fn) | |
require 'rubygems' | |
require 'sqlite3' | |
db=SQLite3::Database.new(fn) | |
db.execute("CREATE TABLE testable (t1 INTEGER PRIMARY KEY, data TEXT, num DOUBLE, time DATE)") | |
db.execute(%^INSERT INTO testable (data,num,time) VALUES ('This is sample data',#{rand},"#{Time.now}")^) | |
puts db.execute("SELECT * FROM testable") | |
db.execute("DROP TABLE testable") | |
File.delete(fn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment