create, read, update an sqlite database

T

Thufir

This is all from <http://sqlite-ruby.rubyforge.org/sqlite3/faq.html>.
How do interpret the following error pls:

thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ ruby seven.rb
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/
errors.rb:94:in
`check': no such table: test (SQLite3::SQLException)
from
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/
statement.rb:70:in
`initialize'
from
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/
database.rb:183:in
`new'
from
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/
database.rb:183:in
`prepare'
from
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/lib/sqlite3/
database.rb:210:in
`execute'
from seven.rb:4
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ gem search sqlite --both

*** LOCAL GEMS ***

sqlite-ruby (2.2.3)
SQLite/Ruby is a module to allow Ruby scripts to interface with a
SQLite database.

sqlite3-ruby (1.1.0)
SQLite3/Ruby is a module to allow Ruby scripts to interface with a
SQLite3 database.

*** REMOTE GEMS ***
Bulk updating Gem source index for: http://gems.rubyforge.org
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ cat seven.rb
require 'sqlite3'

db = SQLite3::Database.new( "test.db" )
rows = db.execute( "select * from test" )
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ cat /etc/gentoo-release
Gentoo Base System release 1.12.9
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ date
Sun Nov 18 21:39:49 PST 2007
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $



Wasn't it supposed to create test.db in line three?




thanks,

Thufir
 
R

Ryan Davis

thufir@arrakis ~/rubyCode/sqlite $ cat seven.rb
require 'sqlite3'

db = SQLite3::Database.new( "test.db" )
rows = db.execute( "select * from test" )
[cut lots of shit that only makes helping you harder]
Wasn't it supposed to create test.db in line three?

http://sqlite-ruby.rubyforge.org/

"new( file_name, mode=0 )

Create a new Database object that opens the given file. The mode
parameter has no meaning yet, and may be omitted. If the file does not
exist, it will be created if possible."
 
T

Thufir

"new( file_name, mode=0 )

Create a new Database object that opens the given file. The mode
parameter has no meaning yet, and may be omitted. If the file does not
exist, it will be created if possible."


Thank you for the information, I googled it and found <http://sqlite-
ruby.rubyforge.org/classes/SQLite/Database.html> which has an example
that fails for reasons unclear to me but which looks quite promising:


thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ ruby eight.rb
/usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
resultset.rb:71:in `compile': near "table": syntax error
(SQLite::Exceptions::SQLException)
from /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
resultset.rb:71:in `commence'
from /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
resultset.rb:65:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
statement.rb:104:in `new'
from /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
statement.rb:104:in `execute'
from /usr/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3/lib/sqlite/
database.rb:194:in `execute'
from eight.rb:5
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ cat eight.rb
require 'sqlite'

db = SQLite::Database.new( "data.db" )

db.execute( "select * from table" ) do |row|
p row
end

db.close
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $ date
Mon Nov 19 03:34:38 PST 2007
thufir@arrakis ~/rubyCode/sqlite $
thufir@arrakis ~/rubyCode/sqlite $




Are the errors due to something with my ruby setup, gems, or installed
packages such as sqlite? That is, does the example work in another
environment?




thanks,

Thufir
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top