Brian Goldman
Brian Goldman

Reputation: 736

MySQL parameterization in Ruby

Is there any MySQL library for Ruby that supports parameterization? The documentation for mysql2 gives this example:

escaped = client.escape("gi'thu\"bbe\0r's")
results = client.query("SELECT * FROM users WHERE group='#{escaped}'")

And that seems kind of clunky and screw-up-able to me.

Upvotes: 6

Views: 802

Answers (2)

emboss
emboss

Reputation: 39620

Sequel does, too. But for MySQL it only simulates them:

The MySQL ruby driver does not support bound variables, so the bound variable methods fall back to string interpolation.

Upvotes: 3

Mchl
Mchl

Reputation: 62387

Apparently DBI does http://ruby-dbi.rubyforge.org/

Upvotes: 3

Related Questions