Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'mysql'
- db = Mysql.connect('localhost', 'root', 'password', 'test')
- # Maak een query die gegevens opzoekt:
- begin
- query = db.query('select name,city from customers')
- puts "There are #{query.num_rows} records found .."
- query.each do |rec|
- puts rec.inspect
- puts rec[0],rec[1],rec[2]
- end
- rescue
- puts db.errno
- puts db.error
- ensure
- # Close databaseconnection
- db.close if db
- end
Add Comment
Please, Sign In to add comment