Wilson Bilkovich wrote:
> On 9/28/06, Patrick Lynch <lynchnco / patmedia.net> wrote:
>> >> My next app will be put up with Rails...wish me luck...
>>
> First, either:
> gem install mysql --remote
> (pick the Win32 version when/if given a choice.)
> 
> ..or install it by hand from here (needs a compiler):
> http://www.tmtm.org/en/mysql/ruby/
> 
> Once you have that, try running this code.
> 
> require 'rubygems'
> require 'mysql'
> 
> HOST = 'localhost'
> USER = 'root'
> PASSWORD = nil
> DATABASE = 'put_your_database_name_here'
> connection = Mysql.real_connect(HOST, USER, PASSWORD, DATABASE)
> connection.query "show tables" do |result_set|
>   result_set.each {|row| puts row}
> end


> This is painfully low-level, and not really how anyone should be
> writing database code in Ruby. However, if it prints out a list of the
> tables in your database, you know it's working.
> 
> In real life, you should use something like DBI, ActiveRecord, or Og.
> That way you aren't dealing with the nitty-gritty connection details
> all the time, and it is easier to switch databases later.
> 
> DBI is also fairly low-level, but at least it is the same across all
> database platforms.

Worked beautifully! THX. I had been working with MySql previously so I 
had to check on the 'put_your_database_name_here' and thankfully I save 
the password.
(I'm not quite sure what would have to be done if I had lost the 
password).

I've worked extensively with DB2 and SQL Server 2000, so working at a 
low level is no big woops for me, actually, I enjoy working at the this 
level...

If you attend any of the Ruby User Group Meetings, let me know, I'd like 
to thank you in person...

THX,
Pat



-- 
Posted via http://www.ruby-forum.com/.