views:

18

answers:

1

I'm trying to write a rake task for loadin data into my database. My plan is do something like

system "mysql -u foo -pbar database < backup.sql"

but I need to access the config/database.yml data for getting the user, pass and database info. The trik is I don't want to "parse" this file but to access this info in the same way tasks like rake db:reset do that.

How can I do that?

A: 

Like this:

require 'yaml'
conf = YAML.load_file("path/to/database.yml")
thomasfedb