8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0096147 commit ae9bb3bCopy full SHA for ae9bb3b
Manifest.txt
@@ -28,6 +28,7 @@ lib/pg/result.rb
28
sample/async_api.rb
29
sample/async_copyto.rb
30
sample/async_mixed.rb
31
+sample/check_conn.rb
32
sample/copyfrom.rb
33
sample/copyto.rb
34
sample/cursor.rb
sample/check_conn.rb
@@ -0,0 +1,21 @@
1
+#!/usr/bin/env ruby
2
+# vim: set nosta noet ts=4 sw=4:
3
+# encoding: utf-8
4
+
5
+require 'pg'
6
7
+# This is a minimal example of a function that can test an existing PG::Connection and
8
+# reset it if necessary.
9
10
+def check_connection( conn )
11
+ begin
12
+ conn.exec( "SELECT 1" )
13
+ rescue PG::Error => err
14
+ $stderr.puts "%p while testing connection: %s" % [ err.class, err.message ]
15
+ conn.reset
16
+ end
17
+end
18
19
+conn = PG.connect( dbname: 'test' )
20
+check_connection( conn )
21
0 commit comments