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
300 301 302 |
# File 'app/models/myreplicator/export.rb', line 300 def self.connect db establish_connection(ActiveRecord::Base.configurations[db]) end |
.exec_sql(source_db, sql) ⇒ Object
321 322 323 324 |
# File 'app/models/myreplicator/export.rb', line 321 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
308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'app/models/myreplicator/export.rb', line 308 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 |