Method: Inspec::Resources::MysqlSession#query

Defined in:
lib/resources/mysql_session.rb

#query(q, db = '') ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/resources/mysql_session.rb', line 29

def query(q, db = '')
  mysql_cmd = create_mysql_cmd(q, db)
  cmd = inspec.command(mysql_cmd)
  out = cmd.stdout + "\n" + cmd.stderr
  if out =~ /Can't connect to .* MySQL server/ || out.downcase =~ /^error/
    # skip this test if the server can't run the query
    warn("Can't connect to MySQL instance for SQL checks.")
  end

  # return the raw command output
  cmd
end