public
Description: my random ruby scripts
Homepage:
Clone URL: git://github.com/kastner/ruby-junk.git
Click here to lend your support to: ruby-junk and make a donation at www.pledgie.com !
ruby-junk / mysql_gem_example.rb
100755 16 lines (11 sloc) 0.371 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'mysql'
 
my = Mysql.new("localhost", "root", "", "advancing")
 
my.query(<<SQL)
CREATE TABLE IF NOT EXISTS instructors(name VARCHAR(255))
SQL
 
my.query(%Q{INSERT INTO instructors (name) VALUES ("David")})
my.query(%Q{INSERT INTO instructors (name) VALUES ("Erik")})
 
my.query("SELECT * FROM instructors").each_hash do |h|
  puts h.inspect
end