Wednesday, August 24, 2011

Re: [Rails] Re: How to connect Ruby with MySQL (XAMPP)?

On Aug 24, 2011, at 11:37 AM, Amit Bobade wrote:

> Hi,
>
> I got the solution. I just ran a command: gem install mysql and the
> error went away.
>
> Now I am strugling with- how to select data from the mysql table. I
> tried so many ways but no luck.
>
> Could somebody add focus on this?

You're probably going to get more takers on the ruby-talk list, rather
than rails-talk. We're all very busy with our integrated framework,
rather than trying to build a connection to a database with stone
knives and bear skins. (kidding about that!)

You've got a database handle (dbh). Before you close it in your
script, use it to issue a SQL command to the server, like this:

res = dbh.query("SELECT name, category FROM animal")
while row = res.fetch_hash do
printf "%s, %s\n", row["name"], row["category"]
end

This is all from here: http://www.kitebird.com/articles/ruby-mysql.html#TOC_7

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate