Class: Convergence::DatabaseConnector::MysqlConnector
- Inherits:
-
Object
- Object
- Convergence::DatabaseConnector::MysqlConnector
- Defined in:
- lib/convergence/database_connector/mysql_connector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #client(database_name = @config.database) ⇒ Object
-
#initialize(config) ⇒ MysqlConnector
constructor
A new instance of MysqlConnector.
- #schema_client ⇒ Object
Constructor Details
#initialize(config) ⇒ MysqlConnector
Returns a new instance of MysqlConnector.
4 5 6 |
# File 'lib/convergence/database_connector/mysql_connector.rb', line 4 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
2 3 4 |
# File 'lib/convergence/database_connector/mysql_connector.rb', line 2 def config @config end |
Instance Method Details
#client(database_name = @config.database) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/convergence/database_connector/mysql_connector.rb', line 8 def client(database_name = @config.database) @mysql ||= Mysql2::Client.new( host: @config.host, port: @config.port, username: @config.username, password: @config.password, database: database_name ) end |
#schema_client ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/convergence/database_connector/mysql_connector.rb', line 18 def schema_client @schema_mysql ||= Mysql2::Client.new( host: @config.host, port: @config.port, username: @config.username, password: @config.password, database: 'information_schema' ) end |