Class: CodeToQuery::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/code_to_query/runner.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
30
MAX_ROWS_RETURNED =
10_000

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Runner

Returns a new instance of Runner.



14
15
16
# File 'lib/code_to_query/runner.rb', line 14

def initialize(config)
  @config = config
end

Instance Method Details

#run(sql:, binds: []) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/code_to_query/runner.rb', line 18

def run(sql:, binds: [])
  validate_execution_context!

  result = execute_with_timeout(sql, binds)
  format_result(result)
rescue StandardError => e
  handle_execution_error(e, sql)
end