Rubyをはじめたので、とりあえずデータベースに接続してみます。 データベースはMySQLを利用します。 各ライブラリはインストールされているものとします・・・ Ruby/DBI require 'dbi' begin # データベース接続。DBI::DatabaseHandleオブジェクトを作成 db = DBI::connect("dbi:Mysql:database:hostname", "username", "password") sql = "select * from users" rs = db.execute sql # eachで1件ずつオブジェクトをフェッチできる rs.each do |row| puts row.join ", " end # 件数を知りたいときは・・・ puts "#{rs.rows}" # プリペアード・ステーメント sql = "select