Class: NetSystem::PgsqlClient
- Inherits:
-
Client
- Object
- Liza::Unit
- Liza::Controller
- Client
- NetSystem::PgsqlClient
- Defined in:
- lib/net_system/sub/database/clients/pgsql_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 = {}) ⇒ PgsqlClient
5 6 7 8 9 10 11 12 |
# File 'lib/net_system/sub/database/clients/pgsql_client.rb', line 5 def initialize hash={} require "pg" t = Time.now hash = NetBox[:client].get(:pgsql_hash) if hash.empty? @conn = PG::Connection.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/pgsql_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/pgsql_client.rb', line 16 def call sql, *args t = Time.now result = @conn.exec sql, args result ensure log "#{t.diff}s | #{sql} | #{args}" end |
#now ⇒ Object
25 26 27 |
# File 'lib/net_system/sub/database/clients/pgsql_client.rb', line 25 def now call "SELECT NOW();" end |