Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/ruby
- require "mysql2"
- puts "Please enter the title of this Report:"
- title = gets.chomp
- Mysql2::Client.default_query_options.merge!(:as => :array)
- puts "Please enter the host, username, password and database in order:"
- hst = gets.chomp
- user = gets.chomp
- pass = gets.chomp
- db = gets.chomp
- begin
- mysql = Mysql2::Client.new(:hst => hst, :username => user, :password => pass, :database => db)
- rescue Mysql2::Error => e
- puts e.errno
- puts e.error
- retry
- puts "Error: please try again."
- puts "Enter the host, username, password and database:"
- hst = gets.chomp!
- user = gets.chomp!
- pass = gets.chomp!
- db = gets.chomp!
- end
- puts "Successfully accessed #{db}!"
- rescue Mysql2::Error => e
- puts e.errno
- puts e.error
- rescue Mysql2::StandardError => e
- puts e.errno
- puts e.error
- iMac:workspace guy$ ruby File.rb
- Please enter the title of this Report:
- title
- Please enter the host, username, password and database in order:
- 1.2.3.4
- username15
- password123
- db_one
- File.rb:19:in `rescue in <main>': uninitialized constant Mysql2::StandardError (NameError)
- Did you mean? StandardError
- from File.rb:17:in `<main>'
- ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement