Class: RailsRedshiftReplicator::Adapters::SQLite
- Defined in:
- lib/rails_redshift_replicator/adapters/sqlite.rb
Instance Method Summary collapse
- #query_command(sql) ⇒ Object
-
#write(file_path, query_result) ⇒ Integer
Writes query results to a file.
Methods inherited from Generic
#connection, #initialize, #last_record_query_command
Constructor Details
This class inherits a constructor from RailsRedshiftReplicator::Adapters::Generic
Instance Method Details
#query_command(sql) ⇒ Object
7 8 9 |
# File 'lib/rails_redshift_replicator/adapters/sqlite.rb', line 7 def query_command(sql) connection.exec_query sql end |
#write(file_path, query_result) ⇒ Integer
Writes query results to a file
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rails_redshift_replicator/adapters/sqlite.rb', line 15 def write(file_path, query_result) line_number = 0 CSV.open(file_path, "w") do |csv| query_result.each do |row| csv << row.map{ |_,field| field.is_a?(String) ? field.gsub("\n", " ") : field } line_number+=1 end end line_number end |