大家好我正在從數據庫中取回數據並將其存儲在File.i中,我正在以yaml格式存儲數據。紅寶石 - 無法讀取yaml文件
require 'mysql2'
require 'yaml'
client = Mysql2::Client.new(:host => "localhost",:username => 'root' , :password => 'root' , :database => 'jgroup')
results = client.query("SELECT * FROM jivegroup")
File.open("D:/j.yml","w") do |file|
results.each do |index|
file.write(index.to_yaml);
end
end
below is my file "j.yml"
---
groupID: 1000
name: T1
description: ""
creationDate: 1209446456903
modificationDate: 1378128624533
---
groupID: 1001
name: T2
description:
creationDate: 1209446473683
modificationDate: 1378181717000
---
但whenver我試圖加載具有YAML上述文件加載::這是給我的只有第一個記錄。我想加載所有記錄,請幫助。下面 是我讀YML文件
YAML::load(File.read('D:/jivegroup.yml'))
{"groupID"=>1000, "name"=>"T1", "description"=>"", "creationDate"=>1209446456903, "modificationDate"=>1378128624533}
嘿,謝謝你好建議 – user2588480