how to use load comman(in mysql) in ruby?

P

Pen Ttt

in mysql,it can run:
LOAD DATA LOCAL INFILE "/home/pt/test/bal.csv" INTO TABLE bal FIELDS
TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1
LINES;
in my ruby programm:
str="LOAD DATA LOCAL INFILE \"/home/pt/test/bal.csv\" INTO TABLE bal
FIELDS TERMINATED BY ',' ENCLOSED BY ' \"' LINES TERMINATED BY '\\n'
IGNORE 1 LINES;"
puts str
dbh.query(str)
the output is :
LOAD DATA LOCAL INFILE "/home/pt/test/bal.csv" INTO TABLE bal FIELDS
TERMINATED BY ',' ENCLOSED BY ' "' LINES TERMINATED BY '\n' IGNORE 1
LINES;
/home/pt/test/ptb.rb:34:in `query': Field separator argument is not what
is expected; check the manual (Mysql::Error)
from /home/pt/test/ptb.rb:34:in `<main>'
what's the matter?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,155
Messages
2,570,871
Members
47,401
Latest member
CliffGrime

Latest Threads

Top