Afficher un message
Vieux 21/06/2008, 11h51   #5
Leslie Viljoen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sqlite3-ruby problem accessing row values

This program gives what you want:

#!/usr/bin/ruby

require "sqlite3"

query = "select * from moz_bookmarks"
db = SQLite3:atabase.new("test.sqlite")
db.results_as_hash = true
rows = db.execute(query)
rows.each do |row|
#p row
#puts row.class
#p row.methods
puts row['title']
end


The commented bits will you with debugging in the future. They enable
you to see what kind of objects you are dealing with.

The answer to selecting rows by column name is to use
db.results_as_hash as above. This was easily discovered via google.

Go here: http://sqlite-ruby.rubyforge.org/
Click on the 'FAQ' link.

Les

  Réponse avec citation
 
Page generated in 0,06105 seconds with 9 queries