Class: Makanai::Dbms::Mysql
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #execute_sql(sql) ⇒ Object
-
#initialize(config) ⇒ Mysql
constructor
A new instance of Mysql.
Constructor Details
#initialize(config) ⇒ Mysql
Returns a new instance of Mysql.
8 9 10 |
# File 'lib/makanai/dbms/mysql.rb', line 8 def initialize(config) @db = Mysql2::Client.new(config || default_config) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
12 13 14 |
# File 'lib/makanai/dbms/mysql.rb', line 12 def db @db end |
Instance Method Details
#execute_sql(sql) ⇒ Object
14 15 16 |
# File 'lib/makanai/dbms/mysql.rb', line 14 def execute_sql(sql) db.query(sql).to_a.tap { close_db } end |