This may not directly answer your question, but you might benefit from checking out a database abstraction layer. There are several of them for Ruby, most notably ActiveRecord. ActiveRecord comes bundled as the model part of the Ruby on Rails framework, but you can use it "stand-alone" without the rest of Rails.
With it (or something similar) you will be able to more rapidly and accurately create applications, as it provides invaluable tools to communicating with your database--tools you would spend a lot of time developing yourself. Should you ever choose to change your database vendor from MySQL to something else (PostgreSQL or Oracle, for example), you won't have to recode much.