Sha256: 6ad5933f21501a94134deb39a0b6c5c1ec6ad87f3d6c971039888b1cc7f3ac58

Contents?: true

Size: 1.25 KB

Versions: 17

Compression:

Stored size: 1.25 KB

Contents

#! /usr/bin/env ruby
#
# original file src/test/examples/testlibpq.c
# 
require 'postgres'

def main
  pghost = nil
  pgport = nil
  pgoptions = nil
  pgtty = nil
  dbname = "template1"
  begin
    conn = PGconn.connect(pghost,pgport,pgoptions,pgtty,dbname)
    if $DEBUG
      fd = open("/tmp/trace.out","w")
      conn.trace(fd)
    end 
    res = conn.exec("BEGIN")
    res.clear
    res = conn.exec("DECLARE myportal CURSOR FOR select * from pg_database")
    res.clear

    res = conn.exec("FETCH ALL in myportal")
    if (res.status != PGresult::TUPLES_OK)
      raise PGerror,"FETCH ALL command didn't return tuples properly\n"
    end

    for fld in res.fields
      printf("%-15s",fld)
    end
    printf("\n\n")

    res.result.each do |tupl|
      tupl.each do |fld|
	printf("%-15s",fld)
      end
      printf("\n")
    end
    res = conn.exec("CLOSE myportal")
    res = conn.exec("END")
    res.clear
    conn.close

    if $DEBUG
      fl.close
    end
  rescue PGError
    if (conn.status == PGconn::CONNECTION_BAD)
      printf(STDERR, "We have lost the connection to the backend, so ")
      printf(STDERR, "further processing is impossible.  ")
      printf(STDERR, "Terminating.\n")
    else
      printf(STDERR, conn.error)
    end
    exit(1)
  end
end

main



Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
ruby-postgres-0.7.1.2005.11.24-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2006.04.06-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2006.04.05-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2005.12.21-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2005.12.20-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2005.12.19-mswin32 sample/test1.rb
ruby-postgres-0.7.1.2005.11.27-mswin32 sample/test1.rb
postgres-0.7.1 sample/test1.rb
ruby-postgres-0.7.1.2005.11.27 sample/test1.rb
ruby-postgres-0.7.1.2005.12.19 sample/test1.rb
ruby-postgres-0.7.1.2005.11.24 sample/test1.rb
ruby-postgres-0.7.1.2005.12.20 sample/test1.rb
ruby-postgres-0.7.1.2005.11.26 sample/test1.rb
ruby-postgres-0.7.1.2005.11.23 sample/test1.rb
ruby-postgres-0.7.1.2006.04.06 sample/test1.rb
ruby-postgres-0.7.1.2006.04.05 sample/test1.rb
ruby-postgres-0.7.1.2005.12.21 sample/test1.rb