pg_copy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pg_copy.rb +7 -0
- data/lib/pg_copy/copy_to_csv.rb +23 -0
- data/lib/pg_copy/version.rb +3 -0
- data/pg_copy.gemspec +37 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 82d865ae378b95ab956b69ac6231829b6c0c0240
|
4
|
+
data.tar.gz: ef1c2b9b2d0742eb5ef227e36061d8880533d1cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc015125da0d789f149ed15daf1b24f2ad4f04a21f0dc657b9d5af7ee28c6773ab323acbdb10641ac3705978b987d14f6c1dd9424a4299ac08b02a4b13b21b5d
|
7
|
+
data.tar.gz: 385234498337426f1da91ff29da79e4c0cce219c2320b5e9c92353f97bbf5a32e2f87bd39614fb68f76f795cf88829546e7f1b13b8cce2ef044a28a353923259
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# PgCopy
|
2
|
+
|
3
|
+
A wrapper for PostgreSQL's COPY command.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'pg_copy'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install pg_copy
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo:
|
28
|
+
|
29
|
+
* Run `bin/setup` to install dependencies.
|
30
|
+
* Create a database and configure it in `spec/database.yml`.
|
31
|
+
|
32
|
+
Then, run `rake spec` to run the tests. You can also run `bin/console` for an
|
33
|
+
interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
36
|
+
To release a new version, update the version number in `version.rb`, and then
|
37
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
38
|
+
push git commits and tags, and push the `.gem` file
|
39
|
+
to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at
|
44
|
+
https://github.com/[USERNAME]/pg_copy.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pg_copy"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/pg_copy.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module PgCopy
|
2
|
+
class CopyToCSV
|
3
|
+
SQL = 'COPY (%<sql>s) TO STDOUT WITH CSV'.freeze
|
4
|
+
|
5
|
+
def initialize(conn, sql, dest)
|
6
|
+
@conn = conn
|
7
|
+
@sql = sql
|
8
|
+
@dest = dest
|
9
|
+
end
|
10
|
+
|
11
|
+
def copy
|
12
|
+
sql = format(SQL, sql: @sql)
|
13
|
+
|
14
|
+
File.open(@dest, 'wb') do |f|
|
15
|
+
@conn.copy_data(sql) do
|
16
|
+
while line = @conn.get_copy_data
|
17
|
+
f.write(line)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/pg_copy.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pg_copy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pg_copy"
|
8
|
+
spec.version = PgCopy::VERSION
|
9
|
+
|
10
|
+
spec.authors = ['Lenon Marcel',
|
11
|
+
'Rafael Timbó',
|
12
|
+
'Rodolfo Liviero',
|
13
|
+
'Italo Moraes',
|
14
|
+
'Diogo Lisboa',
|
15
|
+
'Pablo Silva']
|
16
|
+
spec.email = ['lenon.marcel@gmail.com',
|
17
|
+
'rafaeltimbosoares@gmail.com',
|
18
|
+
'rodolfoliviero@gmail.com',
|
19
|
+
'itu.moraes@gmail.com',
|
20
|
+
'diogoslisboa@gmail.com',
|
21
|
+
'phsilbr@gmail.com']
|
22
|
+
|
23
|
+
spec.summary = "A wrapper for PostgreSQL's COPY command"
|
24
|
+
spec.description = "A wrapper for PostgreSQL's COPY command"
|
25
|
+
spec.homepage = 'https://github.com/locaweb/pg_copy'
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
|
36
|
+
spec.add_dependency "pg"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pg_copy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lenon Marcel
|
8
|
+
- Rafael Timbó
|
9
|
+
- Rodolfo Liviero
|
10
|
+
- Italo Moraes
|
11
|
+
- Diogo Lisboa
|
12
|
+
- Pablo Silva
|
13
|
+
autorequire:
|
14
|
+
bindir: exe
|
15
|
+
cert_chain: []
|
16
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: bundler
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "~>"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.11'
|
25
|
+
type: :development
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - "~>"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '1.11'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rake
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '10.0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - "~>"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '10.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.0'
|
53
|
+
type: :development
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: pg
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
description: A wrapper for PostgreSQL's COPY command
|
75
|
+
email:
|
76
|
+
- lenon.marcel@gmail.com
|
77
|
+
- rafaeltimbosoares@gmail.com
|
78
|
+
- rodolfoliviero@gmail.com
|
79
|
+
- itu.moraes@gmail.com
|
80
|
+
- diogoslisboa@gmail.com
|
81
|
+
- phsilbr@gmail.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- ".gitignore"
|
87
|
+
- ".rspec"
|
88
|
+
- ".travis.yml"
|
89
|
+
- Gemfile
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- bin/console
|
93
|
+
- bin/setup
|
94
|
+
- lib/pg_copy.rb
|
95
|
+
- lib/pg_copy/copy_to_csv.rb
|
96
|
+
- lib/pg_copy/version.rb
|
97
|
+
- pg_copy.gemspec
|
98
|
+
homepage: https://github.com/locaweb/pg_copy
|
99
|
+
licenses: []
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.5.1
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: A wrapper for PostgreSQL's COPY command
|
121
|
+
test_files: []
|