From: Park Heesob Date: 2006-12-02T11:08:08+09:00 Subject: Re: mysql source command doesn't work? Hi, >From: Raymond O'connor >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: mysql source command doesn't work? >Date: Sat, 2 Dec 2006 10:21:49 +0900 > >I'm trying to use the mysql 'source' command within a ruby script to run >a batch file, but it doens't seem to work. When I run the source >command straight from mysql, though, it runs just fine. Here's a short >example of what I'm trying to do: > >require 'mysql' >db = Mysql.real_connect(db_host, db_user, db_pass, db_name) >filename = "/Users/test/batch.sql" >db.query "source #{filename}" > > >I keep getting this error when I try to do dbh.query "source >${filename}" > >Error code: 1064 >Error message: You have an error in your SQL syntax; check the manual >that corresponds to your MySQL server version for the right syntax to >use near 'SOURCE /Users/test/batch.sql' at line 1 >Error SQLSTATE: 42000 > > >Anyone have any ideas? Thanks in advance. > 'source' is not an SQL command, but an internal command of the mysql command line client. You could use Ruby's system like this: system("/path/to/mysql -uuser -ppassword database <#{filename}"); Regards, Park Heesob _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/