Wednesday, May 16th, 2007...4:36 pm
GEEK: PostgreSQL connectivity on Cygwin
I found Steve Litt’s Ruby Database Connectivity article quite helpful for configuring ruby access to PostgreSQL on Cygwin. However, I ran into a couple of errors while running the sample files which I detail below:
Hi Steve,
Thanks so much for putting up the Ruby Database Connectivity article. I
found it most helpful when trying to configure postgres running on cygwin.
However, I ran into a couple of difficulties that I thought you might
like to note among the gotchas.
When I first ran your hello.rb script, I got the following error:
./hello.rb.ORIG:35: uninitialized constant Postgres (NameError)
Line 35 is this:
rescue Postgres::PGError => e
The postgres.rb file in the posgres-pr gem simply tries to load the C
binary first, and if it can’t find it, loads the pure ruby bindings:
require ‘postgres-pr/postgres-compat’
PGError appeared to be a class of it’s own in the postgres-compat.rb
file, not a subclass of Postgres. So I changed all of these lines:
rescue Postgres::PGError => e
to this:
rescue PGError => e
And the script ran past that point. But then I got this error message:
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:115:in
`query’: ERROR C0A000 Mcross-database references are not
implemented: “test.information_schema.columns” Fnamespace.c L175
from
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:33:in
`exec’
from ./hello.rb:33
Which came from this line:
res = conn.exec(’SELECT column_name FROM
test.information_schema.columns WHERE table_name=\’rocks\’;')
Of course, I had named my database something other than test, so I had
to change it. After I did, your script ran fine.
Thanks!
A little about my setup:
I’m running PostgreSQL (8.0.7) under cygwin (2.510.2.2) on Windows XP
Professional (Version 2002, Service Pack 2)
Windows XP is in turn running as a virtual OS under Parallels (Build
3170 RC3) running on OS X Tiger 10.4.9 (2.16 GHz Intel Core 2 Duo)
Cygwin and prosgres were installed via the cygwin installer. Ruby was installed via the one-click installer, as well as Rubygems-0.9.2 (via tarball). I installed the pure ruby Postgres bindings (postgres-pr (0.4.0)) via rubygems.
Leave a Reply
You must be logged in to post a comment.