I want to write a script in Ruby to clean up some messed up keys in several copies of the same MySQL schema. I’d like to do something like SHOW CREATE TABLE, then look at what comes back and delete keys if they exist.
I know in the Rails environment you can do this…
ActiveRecord::Base.connection.execute( some sql )
But what you get back is a ‘Result’ object. For this task I need a String so I can analyze it and act accordingly.
You could check the mysql-ruby gem.
Here is a write-up on how to use it: Using the Ruby MySQL Module
More can be found via google