I’m beginner in Ruby, and I’m using for automated tests.
I’m trying to connect SQL to my application.
I need to know how can I transform a vector into a variable. My query returns just 1 row, but I need to turn this vector into a variable.
client = Mysql2::Client.new(:host => "xxx", :username => "xxx", :password => "xxx", :database => "xxx") sqllistar = client.query("SELECT Placa FROM f001_frotas WHERE Placa regexp '^[A-z]' order by rand() LIMIT 1")
I could print the result doing like this:
sqllistar.each(:as => :array) do |row| puts row end
But I need to put the returned value in a variable to use in a method. How can I do that?
Sorry for my English, I’m brazilian.