class Athens::Connection
Attributes
client[R]
database_name[R]
Public Class Methods
new(database: nil, aws_client_override: {})
click to toggle source
# File lib/athens/connection.rb, line 8 def initialize(database: nil, aws_client_override: {}) @database_name = database client_config = { access_key_id: Athens.configuration.aws_access_key, secret_access_key: Athens.configuration.aws_secret_key, region: Athens.configuration.aws_region, profile: Athens.configuration.aws_profile }.merge(aws_client_override).compact @client = Aws::Athena::Client.new(client_config) end
Public Instance Methods
execute(query, request_token: nil, work_group: nil)
click to toggle source
Runs a query against Athena, returning an Athens::Query
object that you can use to wait for it to finish or get the results
# File lib/athens/connection.rb, line 23 def execute(query, request_token: nil, work_group: nil) if @database_name resp = @client.start_query_execution( query_string: query, query_execution_context: context, result_configuration: result_config, client_request_token: request_token, work_group: work_group ) else resp = @client.start_query_execution( query_string: query, result_configuration: result_config ) end return Athens::Query.new(self, resp.query_execution_id) end
Private Instance Methods
context()
click to toggle source
# File lib/athens/connection.rb, line 44 def context Aws::Athena::Types::QueryExecutionContext.new(database: @database_name) end
result_config()
click to toggle source
# File lib/athens/connection.rb, line 48 def result_config Aws::Athena::Types::ResultConfiguration.new( output_location: Athens.configuration.output_location, encryption_configuration: { encryption_option: "SSE_S3" } ) end