From: Bryan JJ Buckley Date: 2008-06-21T18:16:13+09:00 Subject: Re: sqlite3-ruby problem accessing row values 2008/6/20 The Doobs : > I get a "can't convert String into Integer (TypeError)" error about the > print statement in the following code. The sqlite3-ruby library has been > installed successfully on my OS X 10.5 system. The code executes fine if > I replace the print statement with: print "hello". Any suggestions? All > I want to do is iterate through each row in the return set (rows) of the > executed query and look at specific column values. I have run out of > ideas on how to fix this and would appreciate any help. Thanks... > > #!/usr/bin/ruby > > require "sqlite3" > > query = "select * from moz_bookmarks" > db = SQLite3::Database.new("/Users/me/Desktop/places.sqlite") > rows = db.execute(query) # Rows is an array of arrays.... > rows.each do |row| # At this point, "row" is a straightforward array - you need to use Integer indices > print row['title'] # This fails because you cannot use a string as an integer into an array. Try puts row[0] > end > -- > Posted via http://www.ruby-forum.com/. > > -- JJ