Sha256: 8e7779437ec6ec8f7e1c4df4a59ad860b9611e44d88c93d00fbe01975a8318e7
Contents?: true
Size: 589 Bytes
Versions: 3
Compression:
Stored size: 589 Bytes
Contents
# frozen_string_literal: true require "csvsql/version" require 'csv' require 'sqlite3' require 'csvsql/db' require 'csvsql/tracker' module Csvsql def self.execute(sql, csv_data, opts = {}) csvdb = Csvsql::Db.new(opts) csvdb.import(csv_data) pst = Csvsql::Tracker.commit(:execute_query_sql) do csvdb.prepare(sql) end Csvsql::Tracker.commit(:output_format) CSV.generate do |csv| csv << pst.columns.zip(pst.types).map { |c| c.compact.join(':') } pst.each { |line| csv << line } end.tap { Csvsql::Tracker.commit(:output_format) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
csvsql-0.1.3 | lib/csvsql.rb |
csvsql-0.1.2 | lib/csvsql.rb |
csvsql-0.1.1 | lib/csvsql.rb |