Class: Convergence::DatabaseConnector::MysqlConnector

Inherits:
Object
  • Object
show all
Defined in:
lib/convergence/database_connector/mysql_connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MysqlConnector



5
6
7
# File 'lib/convergence/database_connector/mysql_connector.rb', line 5

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/convergence/database_connector/mysql_connector.rb', line 3

def config
  @config
end

Instance Method Details

#client(database_name = @config.database) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/convergence/database_connector/mysql_connector.rb', line 9

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_clientObject



19
20
21
22
23
24
25
26
27
# File 'lib/convergence/database_connector/mysql_connector.rb', line 19

def schema_client
  @schema_mysql ||= Mysql2::Client.new(
    host: @config.host,
    port: @config.port,
    username: @config.username,
    password: @config.password,
    database: 'information_schema'
  )
end