Class: MysqlImport
- Inherits:
-
Object
- Object
- MysqlImport
- Includes:
- Logging
- Defined in:
- lib/mysql_import.rb,
lib/mysql_import/logger.rb,
lib/mysql_import/version.rb
Defined Under Namespace
Modules: Logging Classes: AfterBreak, BeforeBreak, Break, Logger, Result
Constant Summary collapse
- VERSION =
'0.5.5'
Instance Method Summary collapse
- #add(file_path, opts = {}) ⇒ Object
- #import(filters = nil) ⇒ Object
-
#initialize(config, opts = {}) ⇒ MysqlImport
constructor
A new instance of MysqlImport.
Constructor Details
#initialize(config, opts = {}) ⇒ MysqlImport
Returns a new instance of MysqlImport.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mysql_import.rb', line 9 def initialize(config, opts = {}) @stash = [] @lock = opts.fetch(:lock, false) @concurrency = opts.has_key?(:concurrency) ? opts[:concurrency].to_i : 2 pool = @concurrency.zero? ? 1 : @concurrency sql_opts = opts.fetch(:sql_opts, {}) @client = ConnectionPool.new(size: pool) { LoadDataInfile2::Client.new(config, sql_opts) } @result = Result.new end |
Instance Method Details
#add(file_path, opts = {}) ⇒ Object
20 21 22 |
# File 'lib/mysql_import.rb', line 20 def add(file_path, opts = {}) @stash.push([file_path, opts]) end |
#import(filters = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mysql_import.rb', line 24 def import(filters = nil) Parallel.each(filtered_list(filters), parallel_opts) do |args| @client.with do |cli| begin store[:client] = cli import_internal(*args) ensure clear_store end end end end |