I'm trying to load an SQLite3 database with the DBI and I need some
help. Here's the setup I have and the error I'm getting:
the sqlite stuff:
sqlite test
SQLite version 2.8.17
Enter ".help" for instructions
.databases
seq name file
--- ---------------
···
----------------------------------------------------------
0 main /home/noob/test
1 temp /var/tmp/sqlite_nEeVH8LjfjhjMNv
select name, favnum from test;
Me>37
Fred>12
Pervert>69
#!/usr/bin/env ruby
require "dbi"
the script:
db = DBI.connect("DBI:SQLite3:main")
sth = db.execute("select * from test")
sth.fetch_hash do |row|
puts row["name"] + "'s favorite number is " + row["favnum"].to_s
end
db.disconnect
the error:
ruby sqlite.rb
/usr/lib/ruby/1.8/DBD/SQLite3/SQLite3.rb:236:in `initialize': no such
table: test (DBI::ProgrammingError)
from /usr/lib/ruby/1.8/DBD/SQLite3/SQLite3.rb:111:in `new'
from /usr/lib/ruby/1.8/DBD/SQLite3/SQLite3.rb:111:in `prepare'
from /usr/lib/ruby/1.8/dbi.rb:910:in `execute'
from /usr/lib/ruby/1.8/dbi.rb:504:in `execute'
from sqlite.rb:5
--
Posted via http://www.ruby-forum.com/\.