Class: Mysqlknife::MySQL
- Inherits:
-
Object
- Object
- Mysqlknife::MySQL
- Defined in:
- lib/mysqlknife/mysql.rb
Instance Method Summary collapse
- #execute(sql) ⇒ Object
-
#initialize ⇒ MySQL
constructor
A new instance of MySQL.
Constructor Details
#initialize ⇒ MySQL
Returns a new instance of MySQL.
5 6 7 |
# File 'lib/mysqlknife/mysql.rb', line 5 def initialize @cnf = Configs.instance end |
Instance Method Details
#execute(sql) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mysqlknife/mysql.rb', line 9 def execute(sql) conn = Mysql2::Client.new(host: @cnf.mysql_host, port: @cnf.mysql_port, username: @cnf.mysql_username, password: @cnf.mysql_password, database: @cnf.mysql_database) Mysqlknife::Log.new.sql(sql) return conn.query(sql) rescue Mysql2::Error => error Mysqlknife::Log.new.sql_error(error, sql) exit(1) end |