Thufir Hawat
11/19/2007 11:38:00 AM
On Mon, 19 Nov 2007 16:12:23 +0900, Ryan Davis wrote:
> "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