postgres-copy 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -20
- data/README.md +4 -4
- data/lib/postgres-copy/acts_as_copy_target.rb +1 -1
- data/postgres-copy.gemspec +2 -2
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54bb0d22042b8b123bbb05b8e8623277ae46341c
|
4
|
+
data.tar.gz: 3e53876ba09d4fa52fb9f5e1b4621c1ca38032e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e29b1d98f3adfaf797271a68f107cc7cbcc7e56e19cb197d3b2fa16e0590bc9c6e5343c0121ae91edac804d44ae67f8bad66362888417f432213fdc55e22d96a
|
7
|
+
data.tar.gz: 78ba57612286658b71a83e84f71dcbf08525656b42a1b5aceed0c9d6d2ec06ea1fd2631fdede710fe5a90bac29330a9cd5b3a7916b4a655c0ea96ed4d91ed302
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
postgres-copy (1.
|
5
|
-
activerecord (>=
|
4
|
+
postgres-copy (1.3.0)
|
5
|
+
activerecord (>= 5.1)
|
6
6
|
pg (>= 0.17)
|
7
7
|
responders
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (5.
|
13
|
-
actionview (= 5.
|
14
|
-
activesupport (= 5.
|
12
|
+
actionpack (5.1.1)
|
13
|
+
actionview (= 5.1.1)
|
14
|
+
activesupport (= 5.1.1)
|
15
15
|
rack (~> 2.0)
|
16
16
|
rack-test (~> 0.6.3)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
19
|
-
actionview (5.
|
20
|
-
activesupport (= 5.
|
19
|
+
actionview (5.1.1)
|
20
|
+
activesupport (= 5.1.1)
|
21
21
|
builder (~> 3.1)
|
22
|
-
|
22
|
+
erubi (~> 1.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
25
|
-
activemodel (5.
|
26
|
-
activesupport (= 5.
|
27
|
-
activerecord (5.
|
28
|
-
activemodel (= 5.
|
29
|
-
activesupport (= 5.
|
30
|
-
arel (~>
|
31
|
-
activesupport (5.
|
25
|
+
activemodel (5.1.1)
|
26
|
+
activesupport (= 5.1.1)
|
27
|
+
activerecord (5.1.1)
|
28
|
+
activemodel (= 5.1.1)
|
29
|
+
activesupport (= 5.1.1)
|
30
|
+
arel (~> 8.0)
|
31
|
+
activesupport (5.1.1)
|
32
32
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
33
33
|
i18n (~> 0.7)
|
34
34
|
minitest (~> 5.1)
|
35
35
|
tzinfo (~> 1.1)
|
36
|
-
arel (
|
36
|
+
arel (8.0.0)
|
37
37
|
builder (3.2.3)
|
38
38
|
concurrent-ruby (1.0.5)
|
39
39
|
diff-lcs (1.3)
|
40
|
-
|
40
|
+
erubi (1.6.0)
|
41
41
|
i18n (0.8.4)
|
42
42
|
loofah (2.0.3)
|
43
43
|
nokogiri (>= 1.5.9)
|
@@ -55,9 +55,9 @@ GEM
|
|
55
55
|
nokogiri (>= 1.6)
|
56
56
|
rails-html-sanitizer (1.0.3)
|
57
57
|
loofah (~> 2.0)
|
58
|
-
railties (5.
|
59
|
-
actionpack (= 5.
|
60
|
-
activesupport (= 5.
|
58
|
+
railties (5.1.1)
|
59
|
+
actionpack (= 5.1.1)
|
60
|
+
activesupport (= 5.1.1)
|
61
61
|
method_source
|
62
62
|
rake (>= 0.8.7)
|
63
63
|
thor (>= 0.18.1, < 2.0)
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ class User < ActiveRecord::Base
|
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
|
-
This will add the
|
35
|
+
This will add the additional class methods to your model:
|
36
36
|
|
37
37
|
* copy_to
|
38
38
|
* copy_to_string
|
@@ -42,7 +42,7 @@ This will add the aditiontal class methods to your model:
|
|
42
42
|
### Using copy_to and copy_to_string
|
43
43
|
|
44
44
|
You can go to the rails console and try some cool things first.
|
45
|
-
The first and most basic use case, let's copy the
|
45
|
+
The first and most basic use case, let's copy the entire content of a database table to a CSV file on the database server disk.
|
46
46
|
Assuming we have a users table and a User AR model:
|
47
47
|
|
48
48
|
```ruby
|
@@ -83,7 +83,7 @@ Or, if you have enough memory, you can read all table contents to a string using
|
|
83
83
|
puts User.copy_to_string
|
84
84
|
```
|
85
85
|
|
86
|
-
Another
|
86
|
+
Another interesting feature of copy_to is that it uses the scoped relation, it means that you can use ARel
|
87
87
|
operations to generate different CSV files according to your needs.
|
88
88
|
Assuming we want to generate a file only with the names of users 1, 2 and 3:
|
89
89
|
|
@@ -144,7 +144,7 @@ User.copy_from "/tmp/users.csv" do |row|
|
|
144
144
|
end
|
145
145
|
```
|
146
146
|
|
147
|
-
The above
|
147
|
+
The above example will always change the value of the first column to "fixed string" before storing it into the database.
|
148
148
|
For each iteration of the block row receives an array with the same order as the columns in the CSV file.
|
149
149
|
|
150
150
|
|
@@ -19,7 +19,7 @@ module PostgresCopy
|
|
19
19
|
|
20
20
|
if path
|
21
21
|
raise "You have to choose between exporting to a file or receiving the lines inside a block" if block_given?
|
22
|
-
connection.execute "COPY (#{self.all.to_sql}) TO #{
|
22
|
+
connection.execute "COPY (#{self.all.to_sql}) TO '#{sanitize_sql(path)}' WITH #{options_string}"
|
23
23
|
else
|
24
24
|
connection.raw_connection.copy_data "COPY (#{self.all.to_sql}) TO STDOUT WITH #{options_string}" do
|
25
25
|
while line = connection.raw_connection.get_copy_data do
|
data/postgres-copy.gemspec
CHANGED
@@ -5,7 +5,7 @@ $:.unshift lib unless $:.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "postgres-copy"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.3.0"
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.required_ruby_version = ">= 1.9.3"
|
11
11
|
s.authors = ["Diogo Biazus"]
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.summary = "Put COPY command functionality in ActiveRecord's model class"
|
22
22
|
|
23
23
|
s.add_dependency "pg", ">= 0.17"
|
24
|
-
s.add_dependency "activerecord", '>=
|
24
|
+
s.add_dependency "activerecord", '>= 5.1'
|
25
25
|
s.add_dependency "responders"
|
26
26
|
s.add_development_dependency "bundler"
|
27
27
|
s.add_development_dependency "rdoc"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres-copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diogo Biazus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -29,9 +29,6 @@ dependencies:
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4.0'
|
34
|
-
- - "<"
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '5.1'
|
37
34
|
type: :runtime
|
@@ -39,9 +36,6 @@ dependencies:
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '4.0'
|
44
|
-
- - "<"
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: '5.1'
|
47
41
|
- !ruby/object:Gem::Dependency
|