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

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

#configObject (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_clientObject



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