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
213 214 215 |
# File 'app/models/myreplicator/export.rb', line 213 def self.connect db establish_connection(ActiveRecord::Base.configurations[db]) end |
.exec_sql(source_db, sql) ⇒ Object
234 235 236 237 |
# File 'app/models/myreplicator/export.rb', line 234 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
221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'app/models/myreplicator/export.rb', line 221 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 |