Class: Flydata::SourceMysql::Parser::FlydataMysqlClient
- Inherits:
-
Mysql2::Client
- Object
- Mysql2::Client
- Flydata::SourceMysql::Parser::FlydataMysqlClient
- Defined in:
- lib/flydata/source_mysql/parser/dump_parser.rb
Overview
Custom mysql client that gives access to the last query that was executed using the client which can be helpful when handling exceptions
Instance Attribute Summary collapse
-
#last_query ⇒ Object
Returns the value of attribute last_query.
Instance Method Summary collapse
Instance Attribute Details
#last_query ⇒ Object
Returns the value of attribute last_query.
240 241 242 |
# File 'lib/flydata/source_mysql/parser/dump_parser.rb', line 240 def last_query @last_query end |
Instance Method Details
#query(sql, options = {}) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/flydata/source_mysql/parser/dump_parser.rb', line 242 def query(sql, = {}) @last_query = sql max_retry = [:retry_count] || 0 retry_interval = [:retry_interval] || 3 count = 0 result = nil begin result = super(sql, ) rescue => e count += 1 raise e if max_retry != -1 && count > max_retry yield(count, e) if block_given? sleep retry_interval retry end result end |