Class: Athena::Formats::MYSQL
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sql_parser ⇒ Object
readonly
Returns the value of attribute sql_parser.
Attributes inherited from Base
#config, #output, #record_element
Instance Method Summary collapse
Methods inherited from Base
#convert, #deferred?, directions, format, has_direction?, init, #init, #raw?, #run
Instance Attribute Details
#sql_parser ⇒ Object (readonly)
Returns the value of attribute sql_parser.
37 38 39 |
# File 'lib/athena/formats/sql.rb', line 37 def sql_parser @sql_parser end |
Instance Method Details
#parse(input, &block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/athena/formats/sql.rb', line 39 def parse(input, &block) num = 0 sql_parser.parse(input) { |event, *args| if event == :insert _, _, columns, values = args Athena::Record.new(nil, block) { |record| values.each_with_index { |value, index| if column = columns[index] if column == record_element record.instance_variable_set(:@id, value) end record.update(column, value.to_s, config[column]) end } } num += 1 end } num end |