I am importing a CSV file into a table called import_csv
The table had the columns first_name, last_name, email, phone_number, organization_id
I am importing the CSV with the following code
file = params[:file]
filePath = file.path
fileName = File.basename filePath
pg = ActiveRecord::Base.connection
rc = pg.raw_connection
rc.exec("COPY import_csv (first_name, last_name, email, phone_number) FROM STDIN WITH CSV")
file = File.open(filePath)
file::gets
while !file.eof?
# Add row to copy data
rc.put_copy_data(file.readline)
end
I want to know how i can set the organization_id field without having to have it in the .CSV file that i am importing.