Class: Bricolage::MySQLDataSource
Constant Summary
Constants inherited
from DataSource
DataSource::CLASSES
Instance Attribute Summary collapse
Attributes inherited from DataSource
#context, #logger, #name
Instance Method Summary
collapse
Methods inherited from DataSource
get_class, new_for_type, #open_for_batch, #redshift_loader_source?
Constructor Details
#initialize(**mysql_options) ⇒ MySQLDataSource
Returns a new instance of MySQLDataSource.
13
14
15
16
|
# File 'lib/bricolage/mysqldatasource.rb', line 13
def initialize(**mysql_options)
@mysql_options = mysql_options
@client = nil
end
|
Instance Attribute Details
#mysql_options ⇒ Object
Returns the value of attribute mysql_options.
18
19
20
|
# File 'lib/bricolage/mysqldatasource.rb', line 18
def mysql_options
@mysql_options
end
|
Instance Method Details
#database ⇒ Object
36
37
38
|
# File 'lib/bricolage/mysqldatasource.rb', line 36
def database
@mysql_options[:database]
end
|
#host ⇒ Object
20
21
22
|
# File 'lib/bricolage/mysqldatasource.rb', line 20
def host
@mysql_options[:host]
end
|
#new_task ⇒ Object
40
41
42
|
# File 'lib/bricolage/mysqldatasource.rb', line 40
def new_task
MySQLTask.new(self)
end
|
#open ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/bricolage/mysqldatasource.rb', line 44
def open
@client = Mysql2::Client.new(**@mysql_options)
begin
yield self
ensure
c = @client
@client = nil
c.close
end
end
|
#password ⇒ Object
32
33
34
|
# File 'lib/bricolage/mysqldatasource.rb', line 32
def password
@mysql_options[:password]
end
|
#port ⇒ Object
24
25
26
|
# File 'lib/bricolage/mysqldatasource.rb', line 24
def port
@mysql_options[:port]
end
|
#query(sql, **opts) ⇒ Object
55
56
57
58
59
|
# File 'lib/bricolage/mysqldatasource.rb', line 55
def query(sql, **opts)
logger.info "[SQL] #{sql}"
connection_check
@client.query(sql, **opts)
end
|
#username ⇒ Object
28
29
30
|
# File 'lib/bricolage/mysqldatasource.rb', line 28
def username
@mysql_options[:username]
end
|