Method: ElasticDot::Command::Db.console

Defined in:
lib/elasticdot/command/db.rb

.console(opts) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/elasticdot/command/db.rb', line 37

def self.console(opts)
  unless which 'mysql'
    puts 'MySQL client is not installed.'
    puts 'Please install it to proceed.'
    exit 1
  end

  find_db! opts

  info = api.get("/databases/#{@db}")

  uri = URI.parse info['uri']

  puts 'Attaching... '
  system "mysql -f -u#{info['user']} -p#{info['pass']} -h#{uri.host} -P#{uri.port} #{info['name']}"
end