Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.import(file)
- conn = ActiveRecord::Base.connection
- rc = conn.raw_connection
- rc.exec("COPY callers (your_attributes) FROM STDIN WITH CSV")
- file = File.open("#{file.path}", 'r')
- while !file.eof?
- rc.put_copy_data(file.readline)
- end
- rc.put_copy_end
- while res = rc.get_result
- if e_message = res.error_message
- p e_message
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement