我一直在尝试在准备之后放入一些已执行的语句。这样做的目的是清理我以前从未做过的数据输入。我按照here的步骤进行了操作,但我没有得到我想要的结果。
以下是我所拥有的:
require 'sqlite3'
$db = SQLite3::Database.open "congress_poll_results.db"
def rep_pull(state)
pull = $db.prepare("SELECT name, location FROM congress_members WHERE location = ?")
pull.bind_param 1, state
puts pull.execute
end
rep_pull("MN")
=> #<SQLite3::ResultSet:0x2e69e00>
我期待的是MN中的代表列表,但我只是得到&#34; SQLite3 :: ResultSet:0x2e69e00&#34;的事情。
我在这里缺少什么?非常感谢。
答案 0 :(得分:1)
试试这个
def rep_pull(state)
pull = $db.prepare("SELECT name, location FROM congress_members WHERE location = ?")
pull.bind_param 1, state
pull.execute do |row|
p row
end
end