Sha256: 8a513f66df7b684adefd8276ed80264cf7b430fe8bbefbab11bb0361ec1fab5c

Contents?: true

Size: 449 Bytes

Versions: 84

Compression:

Stored size: 449 Bytes

Contents

#!/usr/bin/env ruby
# vim: set nosta noet ts=4 sw=4:
# encoding: utf-8

require 'pg'

# This is a minimal example of a function that can test an existing PG::Connection and
# reset it if necessary.

def check_connection( conn )
	begin
		conn.exec( "SELECT 1" )
	rescue PG::Error => err
		$stderr.puts "%p while testing connection: %s" % [ err.class, err.message ]
		conn.reset
	end
end

conn = PG.connect( dbname: 'test' )
check_connection( conn )

Version data entries

84 entries across 84 versions & 6 rubygems

Version Path
jruby-pg-0.1-java sample/check_conn.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/pg-0.20.0/sample/check_conn.rb
pg-0.20.0-x86-mingw32 sample/check_conn.rb
pg-0.20.0-x64-mingw32 sample/check_conn.rb
pg-0.20.0 sample/check_conn.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/check_conn.rb
pg-0.19.1.pre20170124220800-x64-mingw32 sample/check_conn.rb
pg-0.19.1.pre20170124220800-x86-mingw32 sample/check_conn.rb
pg-0.19.1.pre20170124220800 sample/check_conn.rb
pg-0.19.1.pre20170115074000-x64-mingw32 sample/check_conn.rb
pg-0.19.1.pre20170115074000-x86-mingw32 sample/check_conn.rb
pg-0.19.1.pre20170115074000 sample/check_conn.rb
pg-0.19.0.pre20170115074000 sample/check_conn.rb
pg-0.19.0-x86-mingw32 sample/check_conn.rb
pg-0.19.0-x64-mingw32 sample/check_conn.rb
pg-0.19.0 sample/check_conn.rb
pg-0.19.0.pre20160904200247-x86-mingw32 sample/check_conn.rb
pg-0.19.0.pre20160904200247-x64-mingw32 sample/check_conn.rb
pg-0.19.0.pre20160904200247 sample/check_conn.rb
pg-0.19.0.pre20160820113039-x86-mingw32 sample/check_conn.rb