Class: DataTaster::MysqlSource
- Inherits:
-
Object
- Object
- DataTaster::MysqlSource
- Defined in:
- lib/data_taster/adapters/mysql_source.rb,
sig/data_taster.rbs
Instance Attribute Summary collapse
-
#source_client ⇒ Object
readonly
Returns the value of attribute source_client.
Instance Method Summary collapse
- #database ⇒ String
-
#initialize(source_client:) ⇒ MysqlSource
constructor
A new instance of MysqlSource.
- #query(sql) ⇒ Object
- #table_names ⇒ Array[String]
Constructor Details
#initialize(source_client:) ⇒ MysqlSource
Returns a new instance of MysqlSource.
7 8 9 |
# File 'lib/data_taster/adapters/mysql_source.rb', line 7 def initialize(source_client:) @source_client = source_client end |
Instance Attribute Details
#source_client ⇒ Object (readonly)
Returns the value of attribute source_client.
5 6 7 |
# File 'lib/data_taster/adapters/mysql_source.rb', line 5 def source_client @source_client end |
Instance Method Details
#database ⇒ String
15 16 17 |
# File 'lib/data_taster/adapters/mysql_source.rb', line 15 def database source_client.[:database] end |
#query(sql) ⇒ Object
11 12 13 |
# File 'lib/data_taster/adapters/mysql_source.rb', line 11 def query(sql) source_client.query(sql) end |
#table_names ⇒ Array[String]
19 20 21 |
# File 'lib/data_taster/adapters/mysql_source.rb', line 19 def table_names query("SHOW tables").map { |row| row[row.keys.first] } end |