outsert 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/outsert +31 -0
- data/lib/outsert.rb +2 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3d05ef4c69385101cdbeab7eea1a0b3a83438427822bf1813b0d90bce8c5552
|
4
|
+
data.tar.gz: 70a828be3b217cd9130ad0438c9b7e565c16ae5b918613fe1af190d6bdc32b9c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db0c8b2cd870efee682c39da8f21d07471e6d46e3d8c97cd1bc540563ece22fe29f99e51001a1ea6899549e0104fcd1a995daa1ea67148a027dfae751e35ea59
|
7
|
+
data.tar.gz: 04f3b9016758c884c344c01047a87daba211fa0825a9b89e7d884b7fe4b19620d6fadb0dcc7dbecd6b8475249ee13689ab2554805f2a5fd1be82526717aeeaf8
|
data/bin/outsert
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
delimiter = ','
|
5
|
+
table_name = 'table_name'
|
6
|
+
|
7
|
+
while arg = ARGV.shift
|
8
|
+
key = arg.split('=').first
|
9
|
+
value = arg.split('=').last
|
10
|
+
|
11
|
+
if key == '--delimiter'
|
12
|
+
delimiter = value
|
13
|
+
end
|
14
|
+
if key == '--table'
|
15
|
+
table_name = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ARGF.each_line do |line|
|
20
|
+
if ARGF.lineno == 2
|
21
|
+
columns = line.strip.split(delimiter).map {|column| "\"#{column}\"" }
|
22
|
+
puts "INSERT INTO #{table_name} (#{columns.join(', ')}) VALUES"
|
23
|
+
else
|
24
|
+
values = line.strip.split(delimiter).map {|column| "\"#{column}\"" }.join(',')
|
25
|
+
if ARGF.eof?
|
26
|
+
puts "(#{values});"
|
27
|
+
else
|
28
|
+
puts "(#{values}),"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/outsert.rb
ADDED
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: outsert
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SUGI Kohei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Generate Insert Statement from select statement result csv
|
14
|
+
email: koheisg@hey.com
|
15
|
+
executables:
|
16
|
+
- outsert
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/outsert
|
21
|
+
- lib/outsert.rb
|
22
|
+
homepage: https://rubygems.org/gems/outsert
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.2.15
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: outsert from (select * from users)
|
45
|
+
test_files: []
|