Class: Myreplicator::Export::SourceDb
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Myreplicator::Export::SourceDb
- Defined in:
- app/models/myreplicator/export.rb
Overview
Inner Class that connects to the source database Handles connecting to multiple databases
Class Method Summary collapse
- .connect(db) ⇒ Object
- .exec_sql(source_db, sql) ⇒ Object
-
.get_tables(db) ⇒ Object
Returns tables as an Array releases the connection.
Class Method Details
.connect(db) ⇒ Object
297 298 299 |
# File 'app/models/myreplicator/export.rb', line 297 def self.connect db establish_connection(ActiveRecord::Base.configurations[db]) end |
.exec_sql(source_db, sql) ⇒ Object
318 319 320 321 |
# File 'app/models/myreplicator/export.rb', line 318 def self.exec_sql source_db,sql SourceDb.connect(source_db) return SourceDb.connection.execute(sql) end |
.get_tables(db) ⇒ Object
Returns tables as an Array releases the connection
305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'app/models/myreplicator/export.rb', line 305 def self.get_tables(db) tables = [] begin self.connect(db) tables = self.connection.tables self.connection_pool.release_connection rescue Mysql2::Error => e puts "Connection to #{db} Failed!" puts e. end return tables end |