Sha256: a5971e2e3b8008ecc9394eef35e12f9ae5f54ccbb8c34c1a65ff5508903c44c8

Contents?: true

Size: 636 Bytes

Versions: 2

Compression:

Stored size: 636 Bytes

Contents

require 'infrataster'
require 'mysql2'

module Infrataster
  module Contexts
    class MysqlQueryContext < BaseContext
      def results
        options = {port: 3306, user: 'root', password: ''}
        if server.options[:mysql]
          options = options.merge(server.options[:mysql])
        end

        server.forward_port(options[:port]) do |address, new_port|
          client = Mysql2::Client.new(
            host: address,
            port: new_port,
            username: options[:user],
            password: options[:password],
          )
          client.query(resource.query)
        end
      end
    end
  end
end



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
infrataster-plugin-mysql-0.1.2 lib/infrataster/contexts/mysql_query_context.rb
infrataster-plugin-mysql-0.1.1 lib/infrataster/contexts/mysql_query_context.rb