Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL parameterization in Ruby

Tags:

mysql

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.

like image 415
Brian Goldman Avatar asked Aug 24 '11 22:08

Brian Goldman


2 Answers

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.

like image 163
emboss Avatar answered Oct 23 '22 05:10

emboss


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

like image 21
Mchl Avatar answered Oct 23 '22 05:10

Mchl