sample/test_binary_values.rb in pg-0.12.2 vs sample/test_binary_values.rb in pg-0.13.0.pre298
- old
+ new
@@ -1,20 +1,18 @@
#!/usr/bin/env ruby1.9.1
require 'pg'
-connhash = { :dbname => 'test' }
-
-db = PGconn.connect( connhash )
+db = PG.connect( :dbname => 'test' )
db.exec "DROP TABLE IF EXISTS test"
db.exec "CREATE TABLE test (a INTEGER, b BYTEA)"
a = 42
b = [1, 2, 3]
-db.exec "INSERT INTO test(a, b) VALUES($1::int, $2::bytea)", \
-[a, {:value => b.pack('N*'), :format => 1}]
+db.exec "INSERT INTO test(a, b) VALUES($1::int, $2::bytea)",
+ [a, {:value => b.pack('N*'), :format => 1}]
-db.exec "SELECT a::int, b::bytea FROM test LIMIT 1", [], 1 do |res|
+db.exec( "SELECT a::int, b::bytea FROM test LIMIT 1", [], 1 ) do |res|
res.nfields.times do |i|
puts "Field %d is: %s, a %s (%s) column from table %p" % [
i,
res.fname( i ),