Class: Kiba::Plus::Source::Mysql
- Inherits:
-
Object
- Object
- Kiba::Plus::Source::Mysql
- Includes:
- Helper
- Defined in:
- lib/kiba/plus/source/mysql.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(options = {}) ⇒ Mysql
constructor
A new instance of Mysql.
Methods included from Helper
#format_sql, #mysql2_connect_hash, #scheme
Constructor Details
#initialize(options = {}) ⇒ Mysql
Returns a new instance of Mysql.
14 15 16 17 18 19 20 21 |
# File 'lib/kiba/plus/source/mysql.rb', line 14 def initialize( = {}) = .assert_valid_keys( :connect_url, :query ) @client = Mysql2::Client.new(mysql2_connect_hash(connect_url)) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'lib/kiba/plus/source/mysql.rb', line 12 def client @client end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/kiba/plus/source/mysql.rb', line 12 def end |
Instance Method Details
#each ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kiba/plus/source/mysql.rb', line 23 def each Kiba::Plus.logger.info query results = client.query(query, as: :hash, symbolize_keys: true, stream: true, cache_rows: false) results.each do |row| yield(row) end end |