Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'mysql'
- begin
- con = Mysql.new 'localhost', 'user12', '34klq*'
- con.list_dbs.each do |db|
- puts db
- end
- rescue Mysql::Error => e
- puts e.errno
- puts e.error
- ensure
- con.close if con
- end
- ## Command Line
- ubuntu@ip-10-252-56-122:~$ ruby test_db_connect.rb
- information_schema
- golf
- test_db_connect.rb:13:in `<main>': undefined local variable or method `e' for main:Object (NameError)
- ubuntu@ip-10-252-56-122:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement