How to output the name of the db

You can grab a raw connection from an ActiveRecord based model object and ask it nicely:

aro.connection.adapter_name => “MySQL”

I've been able to grab the current values for migrations using the following:

ActiveRecord::Base.connection.instance_values['config'][:database] ActiveRecord::Base.connection.instance_values['config'][:host] ActiveRecord::Base.connection.instance_values['config'][:username] ActiveRecord::Base.connection.instance_values['config'][:password]

Using those I can do a system call to run the command line mysql binary to import SQL data into newly created tables that are mostly used for static lookup tables that rarely change. When we get a new dump file I reload the sites manually and then check the new SQL dump file into SVN so that anyone doing a migrate will load the latest copy.

    # use current values from database.yml (already loaded into ActiveRecord)     host = ActiveRecord::Base.connection.instance_values['config'][:host]     username = ActiveRecord::Base.connection.instance_values['config'][:username]     password = ActiveRecord::Base.connection.instance_values['config'][:password]     database = ActiveRecord::Base.connection.instance_values['config'][:database]

    system "mysql -h#{host} -u#{username} -p#{password} #{database} " +       "<db/zipcodes.import.sql"

David

Steve Longdo wrote: