Forum: Ruby on Rails Running SQL file from inside rake task

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joe P. (Guest)
on 2008-10-16 22:57
My friends,

I have a rake task that I'm running to initialize some stuff for new
servers.

I need to run a SQL file from inside that rake task.  It's just a big,
raw SQL file.

How can I run the SQL file from inside the rake task?

Thanks in advance for any good advice.
Freddy A. (Guest)
on 2008-10-17 00:20
(Received via mailing list)
`mysql -uroot databasename < sqlfile.sql`
Andrew B. (Guest)
on 2008-10-17 03:12
(Received via mailing list)
ActiveRecord::Base.connection.execute( <file contents here> )
This topic is locked and can not be replied to.