Sha256: 98bd95c415f0141effe96f19b8b6f5839fd8b2f1847c6c9a6ed8de48bb2c8ca6

Contents?: true

Size: 1.22 KB

Versions: 17

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

# Boxcars is a framework for running a series of tools to get an answer to a question.
module Boxcars
  # A Boxcar that interprets a prompt and executes Sequel SQL code to get answers
  class SQLSequel < SQLBase
    # @param connection [SEQUEL Database object] The Sequel connection to use for this boxcar.
    # @param tables [Array<String>] The tables to use for this boxcar. Will use all if nil.
    # @param except_tables [Array<String>] The tables to exclude from this boxcar. Will exclude none if nil.
    # @param kwargs [Hash] Any other keyword arguments to pass to the parent class. This can include
    #   :name, :description, :prompt, :top_k, :stop, and :engine
    def initialize(connection: nil, tables: nil, except_tables: nil, **kwargs)
      super(connection: connection, tables: tables, except_tables: except_tables, **kwargs)
    end

    private

    def table_schema(table)
      ["CREATE TABLE #{table} (",
       connection&.schema(table)&.map { |c| " #{c[0]} #{c[1][:type]} #{c[1][:allow_null] ? "NULL" : "NOT NULL"}" }&.join(",\n"),
       ");"].join("\n")
    end

    def dialect
      connection.database_type
    end

    def get_output(code)
      connection[code].all
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
boxcars-0.4.10 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.9 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.8 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.7 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.6 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.5 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.4 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.3 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.2 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.1 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.4.0 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.3.5 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.3.4 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.3.3 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.3.2 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.3.1 lib/boxcars/boxcar/sql_sequel.rb
boxcars-0.2.16 lib/boxcars/boxcar/sql_sequel.rb