DBI and SQLite3

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;

#!/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


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:innew’
from /usr/lib/ruby/1.8/DBD/SQLite3/SQLite3.rb:111:in prepare' from /usr/lib/ruby/1.8/dbi.rb:910:inexecute’
from /usr/lib/ruby/1.8/dbi.rb:504:in `execute’
from sqlite.rb:5

Dafydd F. wrote:

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”.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs