Sha256: f67cfe567260a6d2873822d85f6f188c0ce4d2c1d78e347947af9e16e4ef0318
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
#! /usr/bin/env ruby require 'optparse' lib = File.expand_path("../../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'csvsql' options = {} OptionParser.new do |opts| opts.banner = "Csvsql #{Csvsql::VERSION}\nUsage: csvsql [options] SQL" opts.version = Csvsql::VERSION opts.on('-i', '--input path', "CSV file path, optional. read from stdin if no give") do |path| options[:csv_path] = path end opts.on('-c', '--use-cache', "Cache data in ~/.csvsql_cache. it will still reload if file was changed") do options[:use_cache] = true end opts.on( '-b', '--batch-rows n', "How many rows to import per batch. Default value is #{Csvsql::Db::BATCH_ROWS}" ) do |n| options[:batch_rows] = n.to_i end opts.on('-e', '--encoding encoding', "Set the file encoding, default is UTF-8") do |encoding| options[:encoding] = encoding end opts.on('--clear-cache', "Clear all cache data") do options[:clear_cache] = true end opts.on('--debug', "Print debug info") do options[:debug] = true end end.parse! if options[:clear_cache] Csvsql::Db.clear_cache! puts "Completed clear cache." exit end if options[:debug] Csvsql::Tracker.tracker = Csvsql::Tracker.new(Logger.new($stdout)) end csv_data = options[:csv_path] || StringIO.new($stdin.read) puts Csvsql.execute( ARGV[0], csv_data, use_cache: options[:use_cache], batch_rows: options[:batch_rows], sql_error_action: 'exit', encoding: options[:encoding] )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csvsql-0.1.4 | exe/csvsql |