mysql_import 0.4.0 → 0.4.1

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: 549380dea2679b6bf4892f9215ad5a4d0d17bdff
4
- data.tar.gz: c3e0e6387658d654907703dbff2a6689617d430d
3
+ metadata.gz: 7019a15ca8ae5846ef8014d300a886464a8ab02e
4
+ data.tar.gz: 2c8cf6cf654037eb44e047a7cf44874032a4f42d
5
5
  SHA512:
6
- metadata.gz: fb80b62f31d0136fbe3342a836153c8bb63d2402b7949f3cddaf1d0d0d4a7fae3f45f243c5335b9a132474b089edb2ce5425da1979e62d9825660cea5babeafa
7
- data.tar.gz: 514cffbc64a3b531a786f5faee55195beb0f0ce03cb286d2948459e0c24b943cbc1167ae9b458aeeb3ebc96e412531903c1db58e1d4be62d6e32264cf7bea93b
6
+ metadata.gz: 758364cd6d87430daff77c55734aa09e1e9273352138410f91c40352920eb56e5b1a7d3a3d0140269c2ae7cf3f218b481059abfe1ad784716680b33a4845c178
7
+ data.tar.gz: b251b30800e0a56517d8073faa8dae7b73a247e45f2909e91c2cac7c8cf96681fa9c39d1f1d3ebb615526863525d258482e3183c3eacc795329ecb7ab5a29dce
data/README.md CHANGED
@@ -57,6 +57,56 @@ importer.import
57
57
  # => Import to `users` table from three csv files
58
58
  ```
59
59
 
60
+ ### Options
61
+
62
+ #### #initialize
63
+
64
+ Key that can be passed to the second argument of the option of `MysqlImport#initialize` is the four types.
65
+
66
+ concurrency: The number of threads to use. Ruby' GIL is released when the IO waiting occurs in mysql, you might be effective by concurrent processing. (default: 2)
67
+
68
+ ```ruby
69
+ importer = MysqlImport.new(db_config, concurrency: 4)
70
+ ```
71
+
72
+ log: This is an option for the logger. (default: nil)
73
+
74
+ ```ruby
75
+ # File path
76
+ importer = MysqlImport.new(db_config, log: '/path/to/import.log')
77
+ ```
78
+
79
+ ```ruby
80
+ # nil(This is the same as `/dev/null`)
81
+ importer = MysqlImport.new(db_config, log: nil)
82
+ ```
83
+
84
+ ```ruby
85
+ # STDOUT / STDERR
86
+ importer = MysqlImport.new(db_config, log: $stdout)
87
+ ```
88
+
89
+ ```ruby
90
+ # Custom logger
91
+ importer = MysqlImport.new(db_config, log: CustomLogger.new)
92
+ ```
93
+
94
+ debug: This is a flag to the level of the logger to debug. (default: false)
95
+
96
+ ```ruby
97
+ importer = MysqlImport.new(db_config, log: $stdout, debug: true)
98
+ ```
99
+
100
+ sql_opts: This is the option of import to be passed directly to the second argument of `LoadDataInfile2#initialize`.
101
+
102
+ See more details for import options.
103
+
104
+ https://github.com/nalabjp/load_data_infile2#sql-options
105
+
106
+ #### #add
107
+
108
+ The second argument of `MysqlImport#add` will be passed directly to the second argument of `LoadDataInfile2#import`.
109
+
60
110
  See more details for import options.
61
111
 
62
112
  https://github.com/nalabjp/load_data_infile2#sql-options
@@ -67,6 +117,8 @@ If you want to import only a specific file, you can specify the file.
67
117
 
68
118
  The specification of the file will be used regular expression
69
119
 
120
+ #### String
121
+
70
122
  ```ruby
71
123
  importer = MysqlImport.new(db_config)
72
124
  importer.add('/path/to/users.csv')
@@ -74,11 +126,22 @@ importer.add('/path/to/groups.csv')
74
126
  importer.add('/path/to/departments.csv')
75
127
  importer.import('users')
76
128
  # => Only import to `users` table
129
+ ```
130
+
131
+ #### Array
77
132
 
78
- importer.import('users', 'groups')
133
+ ```ruby
134
+ importer.import(['users', 'groups'])
79
135
  # => Import to `users` and `groups` table
80
136
  ```
81
137
 
138
+ If empry:
139
+
140
+ ```ruby
141
+ importer.import([])
142
+ # => Do not import anything
143
+ ```
144
+
82
145
  ### Hook
83
146
 
84
147
  You are able to set the hook immediately before and after import.
@@ -6,17 +6,19 @@ class MysqlImport
6
6
  case out
7
7
  when String
8
8
  obj = ::Logger.new(out)
9
+ obj.level = ::Logger::INFO
9
10
  when NilClass
10
11
  obj = ::Logger.new(nil)
11
12
  when STDOUT, STDERR
12
13
  obj = ::Logger.new(out)
13
14
  obj.formatter = ->(_, _, _, message) { "#{String === message ? message : message.inspect}\n" }
15
+ obj.level = ::Logger::INFO
14
16
  else
15
17
  obj = out
16
18
  end
17
19
 
18
- obj.level = debug ? ::Logger::DEBUG : ::Logger::INFO
19
- __setobj__(obj)
20
+ obj.level = ::Logger::DEBUG if debug
21
+ super(obj)
20
22
  end
21
23
  end
22
24
 
@@ -1,3 +1,3 @@
1
1
  class MysqlImport
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nalabjp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: load_data_infile2
@@ -139,4 +139,3 @@ signing_key:
139
139
  specification_version: 4
140
140
  summary: Simple concurrent importer for MySQL
141
141
  test_files: []
142
- has_rdoc: