Class: NetSystem::MysqlClient
- Inherits:
-
Client
- Object
- Liza::Unit
- Liza::Controller
- Client
- NetSystem::MysqlClient
- Defined in:
- lib/net_system/sub/database/clients/mysql_client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
Methods inherited from Liza::Controller
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Constructor Details
#initialize(hash = {}) ⇒ MysqlClient
5 6 7 8 9 10 11 12 |
# File 'lib/net_system/sub/database/clients/mysql_client.rb', line 5 def initialize hash={} require "mysql2" t = Time.now hash = NetBox[:client].get(:mysql_hash) if hash.empty? @conn = Mysql2::Client.new(hash) ensure log "#{t.diff}s | Connecting to #{hash}" end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
14 15 16 |
# File 'lib/net_system/sub/database/clients/mysql_client.rb', line 14 def conn @conn end |
Instance Method Details
#call(sql, *args) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/net_system/sub/database/clients/mysql_client.rb', line 16 def call sql, *args t = Time.now result = @conn.query sql, *args result ensure log "#{t.diff}s | #{sql} | #{args}" end |
#now ⇒ Object
25 26 27 |
# File 'lib/net_system/sub/database/clients/mysql_client.rb', line 25 def now call "SELECT UTC_TIMESTAMP()" end |