Skip to content

Instantly share code, notes, and snippets.

@libc
Created December 12, 2010 19:42
Show Gist options
  • Select an option

  • Save libc/738267 to your computer and use it in GitHub Desktop.

Select an option

Save libc/738267 to your computer and use it in GitHub Desktop.
Connecting directly to the postgresql server
Setting standard_conforming_strings to off
standard_conforming_strings = off
escape of \" is \\"
Setting standard_conforming_strings to on
standard_conforming_strings = on
escape of \" is \"
--------------------------------------------------------------------------------
Connecting to the postgresql server via pgpool-II
Setting standard_conforming_strings to off
standard_conforming_strings = off
escape of \" is \\"
Setting standard_conforming_strings to on
standard_conforming_strings = on
escape of \" is \\"
require 'rubygems'
require 'pg'
def print_stuff_about_standard_conforming_strings
print "standard_conforming_strings = "
puts @connection.query("SHOW standard_conforming_strings").entries[0]["standard_conforming_strings"]
print %(escape of \\" is )
puts @connection.escape(%(\\"))
end
def perform_testing_on_the_connection
puts "Setting standard_conforming_strings to off"
@connection.query("SET standard_conforming_strings = off")
print_stuff_about_standard_conforming_strings
puts "Setting standard_conforming_strings to on"
@connection.query("SET standard_conforming_strings = on")
print_stuff_about_standard_conforming_strings
end
puts "Connecting directly to the postgresql server"
@connection = PGconn.connect("localhost", 5432, nil, nil, "postgres", "libc", "")
perform_testing_on_the_connection
puts '-'*80
puts "Connecting to the postgresql server via pgpool-II"
@connection = PGconn.connect("localhost", 9977, nil, nil, "postgres", "libc", "")
perform_testing_on_the_connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment