Developer Resources’s Weblog

June 13, 2008

Ruby database access using mysql dbd.

Filed under: Ruby, mysql — Tags: , , — developerresources @ 10:58 pm

Step 1: Install mysql driver for ruby.

You can download package from here

Execute: ruby extconf.rb –with-mysql-config

Then make;make install

Step 2: Write simple ruby client.

  require "mysql"
  my = Mysql.connect("localhost", "", "", "test")
  puts my
  res = my.query("select * from tblMovies")
  res.each do |row|
    puts row[0]+row[1]
  end

That’s it! Now you can access a database with Ruby.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.