Class: Makanai::Dbms::Mysql

Inherits:
Base
  • Object
show all
Defined in:
lib/makanai/dbms/mysql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Mysql

Returns a new instance of Mysql.



8
9
10
11
# File 'lib/makanai/dbms/mysql.rb', line 8

def initialize(config)
  super()
  @db = Mysql2::Client.new(config || default_config)
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



13
14
15
# File 'lib/makanai/dbms/mysql.rb', line 13

def db
  @db
end

Instance Method Details

#execute_sql(sql) ⇒ Object



15
16
17
# File 'lib/makanai/dbms/mysql.rb', line 15

def execute_sql(sql)
  db.query(sql).to_a.tap { close_db }
end