Please add some examples with transactions.
I get  command out of sync error
the only way for me is to avoid transactions and  prepare the statement list, one per line in a variable and then:
mySQLstatements.each_line  do |line|
  client.query(line)
end
but I risk that someone else execute a query between statements.