How to work with non-CRUD SQL statements?



I have a few database admin-related functions that I want to integrate
into a rails app. Some specific MySQL commands are GRANT and REVOKE
that do not return a recordset, and “SHOW PROCESSLIST” which does return
a recordset but does not have an underlying table.

I started trying to do this by getting a new connection
ActiveRecord::Base.establish_connection() and working with that. But
the only way I’ve gotten it to work is to supply new connection
credentials. It’s definitely not railsey to maintain connection info in
two places.

How can I make a second connnection to whichever db is active in
database.yml? (ie development, test, production)

Is there a better way to execute something like “create database…” or
GRANT/REVOKE than making a second connection?


Gary H.