------ art_22606_1975672.1210163644641
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
The code what I wrote above helps u to connect to the sql server by modifing
it a lil
require 'mysql'
mysql ysql.init()
mysql.connect('localhost','USERNAME','PASSWORD')
mysql.select_db(' DATABASE NAME')
result ]
result ysql.query("SELECT name FROM users;")
result.each do |x|
puts x.name
end
from the above when u run ur ruby file u can see the result as list of users
in the data base table called users .
name is the column in the users table.
hopefully this should work
You can alwyas change the database type from mysql/postgresql/sqlite3/sql by
modifing in the correct place form the above code
cheers,
kranthi.
On Wed, May 7, 2008 at 5:53 PM, Raveendran Jazzez <jazzezravi / gmail.com>
wrote:
> Hi Anukul,
>
> Try this. I am working windows here.
>
> TRY.rb
>
> ***************************************************************
> in
> OS : Windows here
> Ruby : 1.8.6
> DB :Mysql
> Gem :> gem install mysql
> ίΕ
>
> require "mysql"
> #require mysql gem
> connection ysql.connect("localhost", "root", "", "cdcol")
> #localhost ostname
> #root sername of mysql DB
> #""
ssword of mysql DB
> #cdcol B name
> output onnection.query("SELECT * FROM cds;")
> #cds able name
> output.each do |x|
> puts x.inspect
> end
>
> ***************************************************************
>
> Regards,
> P.Raveendran
> Railsfactory
> http://raveendran.wordpress.com
> --
> Posted via http://www.ruby-forum.com/.
>
>
------ art_22606_1975672.1210163644641--