We have a mysql mixin that does exactly this (which also uses rbmysql).  Is that for some reason not suitable for what you're trying to do here?