csv2psql 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8617b9028668a6a28cd5185dc0eb6a79effda90
4
- data.tar.gz: b7808d63c2ec216005dc407aa8b200638b5344e5
3
+ metadata.gz: 6f5f61f71e9f7603d48dc14ef87523cc694aa2d1
4
+ data.tar.gz: b94b1da7149fc9440b9a32fd814759d65fe1d6cc
5
5
  SHA512:
6
- metadata.gz: 7ad111c1e05e5b12d191d9e160d248280f76d3768933b03ac41c4ee42c1f0e2962ed5251bade181c52b217fa14da66e1a58acaa6303d1bcb0e778ddb95bebf04
7
- data.tar.gz: 9b75d29f5a8bb8c412b719df00aa88056053f0b209a376166b05f8cdf616e1f400d1f2d872d94fa4ba5afbd38f5339657bf35d792d626cc188486596af988537
6
+ metadata.gz: 3aaadd21b47420361bd97b1b43f331527f5302a89670d58160c5bdadfc67772aa978659651b780da81ed53308f3686890b903558a9c993e58134de14d2105620
7
+ data.tar.gz: a95cbe9e026613a399e62081666ecc3505a26377534b915d1748730018fe92e78a3e5efcb6a28c354788d003a40b1064ac1cc9d569652e35509806700d84e690
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
+ Gemfile.lock
1
2
  *.gem
2
3
  *.rbc
4
+ /.idea
3
5
  /.config
4
6
  /coverage/
5
7
  /InstalledFiles
data/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Tool for transforming CSV into SQL statements
4
4
 
5
+ *Formalities*
6
+
7
+ - [License](https://github.com/korczis/csv2psql/blob/master/LICENSE)
8
+ - [To Do](https://github.com/korczis/csv2psql/blob/master/TODO.md)
9
+ - [Issues](https://github.com/korczis/csv2psql/issues)
10
+
5
11
  ## Status
6
12
 
7
13
  [![Gem Version](https://badge.fury.io/rb/csv2psql.svg)](http://badge.fury.io/rb/csv2psql)
@@ -10,6 +16,18 @@ Tool for transforming CSV into SQL statements
10
16
  [![Code Climate](https://codeclimate.com/github/korczis/csv2psql/badges/gpa.svg)](https://codeclimate.com/github/korczis/csv2psql)
11
17
  [![Dependency Status](https://gemnasium.com/korczis/csv2psql.svg)](https://gemnasium.com/korczis/csv2psql)
12
18
 
19
+
20
+ ## Features
21
+
22
+ - Works outside of box
23
+ - Customizable (parameters can be tweaked)
24
+ - Extendable (external modules can bring functionality)
25
+ - Database aware
26
+ - SQL Dialects sensitive
27
+ - [Drop table](https://github.com/korczis/csv2psql/blob/master/templates/drop_table.sql.erb)
28
+ - [Create table](https://github.com/korczis/csv2psql/blob/master/templates/create_table.sql.erb)
29
+ - [Truncate database](https://github.com/korczis/csv2psql/blob/master/templates/truncate_table.sql.erb)
30
+
13
31
  ## Getting started
14
32
 
15
33
  ```
@@ -30,13 +48,17 @@ csv2psql convert data/sample.csv
30
48
  csv2psql help
31
49
 
32
50
  NAME
33
- csv2psql - csv2psql 0.0.5
51
+ csv2psql - csv2psql 0.0.7 (Codename: Smelly cat)
34
52
 
35
53
  SYNOPSIS
36
54
  csv2psql [global options] command [command options] [arguments...]
37
55
 
38
56
  GLOBAL OPTIONS
39
- --help - Show this message
57
+ -d, --delimiter=arg - Column delimiter (default: ,)
58
+ -h, --[no-]header - Header row included (default: enabled)
59
+ --help - Show this message
60
+ -q, --quote=arg - Quoting character (default: ")
61
+ -s, --separator=arg - Line separator (default: auto)
40
62
 
41
63
  COMMANDS
42
64
  convert - Convert csv file
@@ -57,12 +79,8 @@ SYNOPSIS
57
79
 
58
80
  COMMAND OPTIONS
59
81
  --[no-]create-table - Crate SQL Table before inserts
60
- -d, --delimiter=arg - Column delimiter (default: ,)
61
82
  --[no-]drop-table - Drop SQL Table before inserts
62
- -h, --[no-]header - Header row included (default: enabled)
63
- -q, --quote=arg - Quoting character (default: ")
64
- -s, --separator=arg - Line separator (default: auto)
65
- -t, --table=arg - Table to insert to (default: my_table)
83
+ -t, --table=arg - Table to insert to (default: none)
66
84
  --[no-]transaction - Import in transaction block (default: enabled)
67
85
  --[no-]truncate-table - Truncate SQL Table before inserts
68
86
  ```
@@ -85,8 +103,10 @@ id,Firstname,Lastname,Address.Street,Address.City,Address.Details.Note
85
103
  csv2psql convert data/sample.csv
86
104
 
87
105
  BEGIN;
88
- INSERT INTO my_table(id, firstname, lastname, address_street, address_city, address_details_note) VALUES('12345', 'Joe', 'Doe', '#2140 Taylor Street, 94133', 'San Francisco', 'Pool available');
89
- INSERT INTO my_table(id, firstname, lastname, address_street, address_city, address_details_note) VALUES('45678', 'Jack', 'Plumber', '#111 Sutter St, 94104', 'San Francisco', 'Korean Deli near to main entrance');
106
+ -- Table: my_table
107
+
108
+ INSERT INTO (id, firstname, lastname, address_street, address_city, address_details_note) VALUES('12345', 'Joe', 'Doe', '#2140 Taylor Street, 94133', 'San Francisco', 'Pool available');
109
+ INSERT INTO (id, firstname, lastname, address_street, address_city, address_details_note) VALUES('45678', 'Jack', 'Plumber', '#111 Sutter St, 94104', 'San Francisco', 'Korean Deli near to main entrance');
90
110
  COMMIT;
91
111
  ```
92
112
 
@@ -97,7 +117,6 @@ csv2psql convert --create-table -t pokus data/sample.csv
97
117
 
98
118
  BEGIN;
99
119
  -- Table: pokus
100
- -- DROP TABLE pokus;
101
120
 
102
121
  CREATE TABLE pokus(
103
122
  id TEXT,
@@ -116,10 +135,10 @@ INSERT INTO pokus(id, firstname, lastname, address_street, address_city, address
116
135
  COMMIT;
117
136
  ```
118
137
 
119
- **Convert CSV - Stream directly to Postgre client (psql)**
138
+ **Convert CSV - Stream directly to Postgres client (psql)**
120
139
 
121
140
  ```
122
- csv2psql convert --create-table -t hokus data/sample.csv | psql -h apollocrawler.com -U datathon
141
+ csv2psql convert --create-table -t hokus data/sample.csv | psql
123
142
 
124
143
  BEGIN
125
144
  CREATE TABLE
@@ -155,6 +174,12 @@ INSERT INTO test(id, firstname, lastname, address_street, address_city, address_
155
174
  COMMIT;
156
175
  ```
157
176
 
177
+ **Convert CSV - Load CIA Factbook automagically**
178
+
179
+ ```
180
+ csv2psql convert --create-table --drop-table --truncate-table --no-transaction -t test data/cia-data-all.csv | psql
181
+ ```
182
+
158
183
  ## Contributing to csv2psql
159
184
 
160
185
  - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
@@ -167,4 +192,4 @@ COMMIT;
167
192
 
168
193
  ## Copyright
169
194
 
170
- Copyright (c) 2014 Tomas Korcak. See LICENSE for details.
195
+ Copyright (c) 2014 [Tomas Korcak](https://www.linkedin.com/in/korcaktomas). See [LICENSE](https://github.com/korczis/csv2psql/blob/master/LICENSE) for details.
data/TODO.md ADDED
@@ -0,0 +1,12 @@
1
+ # To Do
2
+
3
+ List od task to do
4
+
5
+ ## Tasks
6
+
7
+ - Column names override
8
+ - Data type detection
9
+ - Include/Exclude columns
10
+ - Column datatype guesser (with sha based caching of results)
11
+ - Templates override
12
+ - Custom row formater - no need to override templates