# Help! Beginner in Ruby

**URL:** <https://www.ruby-forum.com/t/help-beginner-in-ruby/252606>\
**Category:** Ruby\
**Tags:** cucumber, capybara\
**Created:** [June 25, 2019, 9:52pm UTC](https://www.ruby-forum.com/t/help-beginner-in-ruby/252606 "2019-06-25T21:52:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henriquevenceslau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/67e7ee/32.png) [@henriquevenceslau](https://www.ruby-forum.com/u/henriquevenceslau)\
**Post date:** [June 25, 2019, 9:52pm UTC](https://www.ruby-forum.com/t/help-beginner-in-ruby/252606/1 "2019-06-25T21:52:59Z")

</div>

Hi guys.  
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.

---

<div class="post-metadata">

**Author:** ![panic\_maven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/47e85d/32.png) [@panic\_maven](https://www.ruby-forum.com/u/panic_maven)\
**Post date:** [June 27, 2019, 5:10am UTC](https://www.ruby-forum.com/t/help-beginner-in-ruby/252606/2 "2019-06-27T05:10:18Z")

</div>

it looks like the result object includes enumerable try:

```ruby
puts sqllistar.first

```

note if a query returns more rows when expecting just one, #first may return the row you didn’t inspect.
