Class: Boxcars::SQLBase Abstract
- Inherits:
-
EngineBoxcar
- Object
- Boxcar
- EngineBoxcar
- Boxcars::SQLBase
- Defined in:
- lib/boxcars/boxcar/sql_base.rb
Overview
A Boxcar that interprets a prompt and executes SQL code to get answers Use one of the subclasses for ActiveRecord or Sequel
Direct Known Subclasses
Constant Summary collapse
- SQLDESC =
the description of this engine boxcar
"useful for when you need to query a database for %<name>s."
- LOCKED_OUT_TABLES =
%w[schema_migrations ar_internal_metadata].freeze
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#the_tables ⇒ Object
Returns the value of attribute the_tables.
Attributes inherited from EngineBoxcar
#engine, #prompt, #stop, #top_k
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
-
#initialize(connection: nil, tables: nil, except_tables: nil, **kwargs) ⇒ SQLBase
constructor
A new instance of SQLBase.
-
#prediction_additional(_inputs) ⇒ Object
Hash The additional variables for this boxcar.
Methods inherited from EngineBoxcar
#apply, #call, #check_output_keys, #extract_code, #generate, #input_key, #input_keys, #output_key, #output_keys, #predict, #prediction_input, #prediction_variables
Methods inherited from Boxcar
#apply, assi, #call, #conduct, hist, #input_keys, #load, #output_keys, #run, #save, syst, user, #validate_inputs, #validate_outputs
Constructor Details
#initialize(connection: nil, tables: nil, except_tables: nil, **kwargs) ⇒ SQLBase
Returns a new instance of SQLBase.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/boxcars/boxcar/sql_base.rb', line 19 def initialize(connection: nil, tables: nil, except_tables: nil, **kwargs) @connection = connection check_tables(tables, except_tables) kwargs[:name] ||= "Database" kwargs[:description] ||= format(SQLDESC, name: name) kwargs[:prompt] ||= my_prompt kwargs[:stop] ||= ["SQLResult:"] super(**kwargs) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
12 13 14 |
# File 'lib/boxcars/boxcar/sql_base.rb', line 12 def connection @connection end |
#the_tables ⇒ Object
Returns the value of attribute the_tables.
12 13 14 |
# File 'lib/boxcars/boxcar/sql_base.rb', line 12 def the_tables @the_tables end |
Instance Method Details
#prediction_additional(_inputs) ⇒ Object
Returns Hash The additional variables for this boxcar.
31 32 33 |
# File 'lib/boxcars/boxcar/sql_base.rb', line 31 def prediction_additional(_inputs) { schema: schema, dialect: dialect }.merge super end |