我想将CSV文件中的数据导入现有的数据库表.我不想保存CSV文件,只需从中获取数据并将其放入现有表中.我正在使用Ruby 1.9.2和Rails 3.
这是我的表:
create_table "mouldings", :force => true do |t|
t.string "suppliers_code"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.integer "supplier_id"
t.decimal "length", :precision => 3, :scale => 2
t.decimal "cost", :precision => 4, :scale => 2
t.integer "width"
t.integer "depth"
end
Run Code Online (Sandbox Code Playgroud)
你能给我一些代码来告诉我最好的方法吗,谢谢.