Can you just shell out to whatever command-line tool your database supports for 
executing large sql files?

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Joe Peck
Sent: Thursday, October 16, 2008 12:36 PM
To: [email protected]
Subject: [Rails] Re: Raw SQL from a Rake Task


Frederick Cheung wrote:
> ActiveRecord::Base.connection.execute(...)
>
> Fred

That seems to work if actual sql code is put in the parenthesis, but how can I 
run SQL out of a sql file in the rake task?

Doing this in the rake task:
ActiveRecord::Base.connection.execute("#{RAILS_ROOT}/db/html_template.sql")

gives me this error:
rake aborted!
Mysql::Error: 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 
'/projects/trieste2/db/html_template.sql' at line 1:
/projects/trieste2/db/html_template.sql


How can I run the sql that is in the sql file?
--
Posted via http://www.ruby-forum.com/.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to