Sha256: ca405cefaff96e021c4098c1da127b00f430bf7d700aeeb061e9ae0887b0755f

Contents?: true

Size: 541 Bytes

Versions: 1

Compression:

Stored size: 541 Bytes

Contents

class NetSystem::PgsqlClient < NetSystem::Client

  # https://www.postgresql.org/
  # https://github.com/ged/ruby-pg
  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

  attr_reader :conn

  def call sql, *args
    t = Time.now
    result = @conn.exec sql, args

    result
  ensure
    log "#{t.diff}s | #{sql} | #{args}"
  end

  def now
    call "SELECT NOW();"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lizarb-1.0.5 lib/net_system/sub/database/clients/pgsql_client.rb