From: Phil Pan Date: 2008-01-18T04:12:59+09:00 Subject: Re: howto insert data into a database? [fixed] Thanks for the tip, I'll look it. I also found the problem. Instead of: system("mysql -u root -pqwerasdf ridespot --execute=\"LOAD DATA LOCAL INFILE \"c:/new.txt\" INTO TABLE foo LINES TERMINATED BY '\r\m'\"") I needed to write: system("mysql -u root -pqwerasdf ridespot --execute=\"LOAD DATA LOCAL INFILE \\\"c:/new.txt\\\" INTO TABLE foo LINES TERMINATED BY '\r\m'\"") Notice how there are 2 extra back slashes... Pretty silly. Matt Todd wrote: > On Jan 17, 2008 12:13 PM, Phil Pan wrote: >> a file into a database: >> 'command' >> >> But it doesn't work. > > If you'd like to not just execute a command in the Ruby script and > have it just be actual Ruby, check out the Sequel library ( > http://sequel.rubyforge.org/ should be one of the URLs though it is a > Google Code project). > > If you want to execute a command in the Ruby script on the > commandline, enclose the command in backticks (shares keys with the > Tilde on my keyboard): > > `mysql -u root -p123456 -D databasename --execute='...'` > > There may be errors with the actual SQL though which may be causing > problems that aren't being shown to you. Try putting "puts" in front > of the command you call so the returned results are shown to you. You > may have to redirect 2>&1. > > Cheers, > Matt Todd -- Posted via http://www.ruby-forum.com/.