Class: Vertica::Query
- Inherits:
-
Object
- Object
- Vertica::Query
- Defined in:
- lib/vertica/query.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#copy_handler ⇒ Object
Returns the value of attribute copy_handler.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#row_handler ⇒ Object
Returns the value of attribute row_handler.
-
#row_style ⇒ Object
Returns the value of attribute row_style.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
Instance Method Summary collapse
-
#initialize(connection, sql, options = {}) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
- #to_s ⇒ Object
- #write(data) ⇒ Object (also: #<<)
Constructor Details
#initialize(connection, sql, options = {}) ⇒ Query
Returns a new instance of Query.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/vertica/query.rb', line 6 def initialize(connection, sql, = {}) @connection, @sql = connection, sql @row_style = [:row_style] || @connection.row_style || :hash @row_handler = [:row_handler] @copy_handler = [:copy_handler] @error = nil @result = Vertica::Result.new(row_style) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/vertica/query.rb', line 3 def connection @connection end |
#copy_handler ⇒ Object
Returns the value of attribute copy_handler.
4 5 6 |
# File 'lib/vertica/query.rb', line 4 def copy_handler @copy_handler end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/vertica/query.rb', line 3 def error @error end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
3 4 5 |
# File 'lib/vertica/query.rb', line 3 def result @result end |
#row_handler ⇒ Object
Returns the value of attribute row_handler.
4 5 6 |
# File 'lib/vertica/query.rb', line 4 def row_handler @row_handler end |
#row_style ⇒ Object
Returns the value of attribute row_style.
4 5 6 |
# File 'lib/vertica/query.rb', line 4 def row_style @row_style end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
3 4 5 |
# File 'lib/vertica/query.rb', line 3 def sql @sql end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vertica/query.rb', line 17 def run @connection.write Vertica::Messages::Query.new(sql) begin ( = @connection.) end until .kind_of?(Vertica::Messages::ReadyForQuery) raise error unless error.nil? return result end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/vertica/query.rb', line 35 def to_s @sql end |