DBI and SQLite3

D

Dafydd Fontenot

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
sqlite> .databases
seq name file
--- ---------------
----------------------------------------------------------
0 main /home/noob/test
1 temp /var/tmp/sqlite_nEeVH8LjfjhjMNv
sqlite> 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
 
P

pierr

Dafydd said:
the error:
ruby sqlite.rb
/usr/lib/ruby/1.8/DBD/SQLite3/SQLite3.rb:236:in `initialize': no such
table: test (DBI::programmingError)

You might want to try "select tbl_name from sqlite_master where
type="table"" to see if there is really a table called "test".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top