I have a ruby script which will read data from some CSV file and import them into sqlite database. I can do this task easily from console using following command:
sqlite> .import <filename> <tablename>
sqlite> .import test.csv PROJECT_REPORT
How can I achieve the same form Ruby script ?
I am doing something similar like following(just a work arround):
CSV.foreach("timelog.csv") do |row|
database.execute("INSERT INTO PROJECT_REPORT(
Date,User,Activity,Comment)
values
(#{row[0]}, '#{row[1]}', '#{row[2]}', '#{row[3]}') ")
end