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: Break, Logger, Result
Constant Summary collapse
- VERSION =
'0.2.0'
Instance Method Summary collapse
- #add(file_path, options = {}) ⇒ Object
- #import(*filters) ⇒ Object
-
#initialize(config, opts = {}, sql_opts = {}) ⇒ MysqlImport
constructor
A new instance of MysqlImport.
Constructor Details
#initialize(config, opts = {}, sql_opts = {}) ⇒ MysqlImport
Returns a new instance of MysqlImport.
8 9 10 11 12 13 14 15 16 |
# File 'lib/mysql_import.rb', line 8 def initialize(config, opts ={}, sql_opts = {}) @stash = [] @fileters = [] @concurrency = opts.has_key?(:concurrency) ? opts[:concurrency].to_i : 2 pool = concurrency.zero? ? 1 : concurrency @client = ConnectionPool.new(size: pool) { LoadDataInfile2::Client.new(config, sql_opts) } @result = Result.new end |
Instance Method Details
#add(file_path, options = {}) ⇒ Object
18 19 20 |
# File 'lib/mysql_import.rb', line 18 def add(file_path, = {}) stash.push([file_path, ]) end |
#import(*filters) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mysql_import.rb', line 22 def import(*filters) Parallel.each(filtered_list(filters), parallel_opts) do |args| client.with do |cli| run_import(cli, *args) end end end |