Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'mysql'
  4.  
  5. begin
  6. con = Mysql.new 'localhost', 'user12', '34klq*'
  7.  
  8. con.list_dbs.each do |db|
  9. puts db
  10. end
  11.  
  12. rescue Mysql::Error => e
  13. puts e.errno
  14. puts e.error
  15.  
  16. ensure
  17. con.close if con
  18. end
  19.  
  20.  
  21. ## Command Line
  22. ubuntu@ip-10-252-56-122:~$ ruby test_db_connect.rb
  23. information_schema
  24. golf
  25. test_db_connect.rb:13:in `<main>': undefined local variable or method `e' for main:Object (NameError)
  26. ubuntu@ip-10-252-56-122:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement