Is there a One True Postgres interface? Is Ruby-postgresmaintained?

J

John Carter

Is there a One true Ruby Interface to Postgres?

All websites I have found so far have "Last Updated" timestamps of
several years ago.

Is ruby-postgres still being maintained?

Running with warnings on,
require 'postgres'
emits this warning...

/opt/ruby/ruby-1.8.6-p114/lib/ruby/1.8/i686-linux/bigdecimal.so: warning: discarding old open

Looking in the postgres.c file I see...

rb_define_singleton_alias(rb_cPGconn, "connect", "new");
rb_define_singleton_alias(rb_cPGconn, "open", "connect");
rb_define_singleton_alias(rb_cPGconn, "setdb", "connect");
rb_define_singleton_alias(rb_cPGconn, "setdblogin", "connect");
rb_define_singleton_alias(rb_cPGconn, "open", "connect");

Deleting the second "open", "connect" gets rid of the warning.

Here's the patch

diff -u postgres.c~ postgres.c
--- postgres.c~ 2005-12-22 04:59:43.000000000 +1300
+++ postgres.c 2008-04-15 10:11:26.000000000 +1200
@@ -2510,7 +2510,6 @@
rb_define_singleton_alias(rb_cPGconn, "open", "connect");
rb_define_singleton_alias(rb_cPGconn, "setdb", "connect");
rb_define_singleton_alias(rb_cPGconn, "setdblogin", "connect");
- rb_define_singleton_alias(rb_cPGconn, "open", "connect");
rb_define_singleton_method(rb_cPGconn, "escape", pgconn_s_escape, 1);
rb_define_singleton_method(rb_cPGconn, "quote", pgconn_s_quote, 1);
rb_define_singleton_alias(rb_cPGconn, "format", "quote");



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
J

John Carter

Is ruby-postgres still being maintained?

Running with warnings on,
require 'postgres'
emits this warning...

/opt/ruby/ruby-1.8.6-p114/lib/ruby/1.8/i686-linux/bigdecimal.so: warning:
discarding old open

Sorry, some version details on that post...

This is against the snapshot version
ruby-postgres-20051221.tar.gz

from
http://ruby.scripting.ca/postgres/

The fault is not in the release version.
ruby-postgres-0.7.1.tar.gz




John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
J

John Carter


Interestingly enough that link also serves up both flavors,
ruby-postgres and ruby-pg, without comment. Is there any discussion
anywhere on the relative merits?

Or is ruby-pg the One True flavour?



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
J

John Carter

Interestingly enough that link also serves up both flavors,
ruby-postgres and ruby-pg, without comment. Is there any discussion
anywhere on the relative merits?

Or is ruby-pg the One True flavour?

Ok, sorry, I have now RTFRM "Read The Fine README" and see that ruby-pg is
indeed The One True Postgres Interface and ruby-postgres is being superceded



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
J

John Carter

Where'd you find that README? In the source -- or is there somewhere to
get it without downloading?

In the basement, in the locked cupboard, the one with the sign "Beware
of the Leopard".... :)) (As you can tell, I'm a Douglas Adams fan...)

It's inside the ruby-pg source bundle.


John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
J

Joel VanderWerf

John said:
In the basement, in the locked cupboard, the one with the sign "Beware
of the Leopard".... :)) (As you can tell, I'm a Douglas Adams fan...)

Funny. I always figured you as an Edgar Rice Burroughs fan. ;)
 
J

John Carter

Funny. I always figured you as an Edgar Rice Burroughs fan. ;)

Actually, it's the other way round....

Check the "X-Apparently-From:" header in my mails.

Now you'll have to excuse me, I must go rescue a scantily clad buxom
maiden in distress from a slobbering alien...

If other readers of this conversation are utterly confused... say
"barsoom" to Google and you will be enlightened....

Well, no, not actually enlightened as such.

Well, at least become informed about an obscure, old fashioned, and
ever so slightly kinky, steam punk corner of literary history.

John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
 
P

Phillip Gawlowski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Carter wrote:

| If other readers of this conversation are utterly confused... say
| "barsoom" to Google and you will be enlightened....
|
| Well, no, not actually enlightened as such.

Careful, otherwise Tarzan may beat you to pulp. ;P


- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

[Abstract art is] a product of the untalented, sold by the unprincipled
~ to the utterly bewildered.
~ -- Al Capp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgEQWkACgkQbtAgaoJTgL9CsgCfY1SZcMHZVz31Oy9Yr1peL+Q5
QKsAnj4G7U97WNnScNUU/bTSFFvyk0ZM
=bRxb
-----END PGP SIGNATURE-----
 
J

Jeff Davis

It seems kind of suboptimal, to me, to only let someone know that
postgres has been superseded by pg *after* something has already been
downloaded and unpacked.

http://ruby-pg.rubyforge.org/svn/ruby-pg/trunk/README

Also, the project description does seem to imply that information in the
255 characters I was allowed for that field.

I haven't gotten around to actually writing a project home page yet,
which is the only other place I could really put that kind of
information. Rubyforge doesn't really offer a long description area.

If you have any specific suggestions that can make it more clear, please
let me know.

Regards,
Jeff Davis
 
J

Jeff Davis

Interestingly enough that link also serves up both flavors,
ruby-postgres and ruby-pg, without comment. Is there any discussion
anywhere on the relative merits?

ruby-postgres had some serious maintenance problems, and was unable to
even build against PostgreSQL 8.3, and my various patches were not
applied.

So, I started maintaining a fork of ruby-postgres with my most important
patches applied, and started a rewrite to address some of the more
fundamental problems. The rewrite is called ruby-pg, and I consider it
to be the best driver available, and it's intended to replace the
others.
Or is ruby-pg the One True flavour?

As far as I can tell, it's the only actively maintained PostgreSQL
driver for Ruby. It's fairly new, but:
* it's well documented (RDoc)
* offers almost all the functionality available from libpq (which is a
lot of functions)
* I'm responsive to bug reports
* I have an expanding set of rspec tests.

The biggest problem I am having with the project is making it work
seamlessly on windows. Several people have tried to help me, but I don't
think the problem has been solved, and I haven't received many specific
suggestions to make it work.

If anyone wants to help me with that, please contact me.

Regards,
Jeff Davis
 
M

M. Edward (Ed) Borasky

Jeff said:
ruby-postgres had some serious maintenance problems, and was unable to
even build against PostgreSQL 8.3, and my various patches were not
applied.

So, I started maintaining a fork of ruby-postgres with my most important
patches applied, and started a rewrite to address some of the more
fundamental problems. The rewrite is called ruby-pg, and I consider it
to be the best driver available, and it's intended to replace the
others.


As far as I can tell, it's the only actively maintained PostgreSQL
driver for Ruby. It's fairly new, but:
* it's well documented (RDoc)
* offers almost all the functionality available from libpq (which is a
lot of functions)
* I'm responsive to bug reports
* I have an expanding set of rspec tests.

The biggest problem I am having with the project is making it work
seamlessly on windows. Several people have tried to help me, but I don't
think the problem has been solved, and I haven't received many specific
suggestions to make it work.

If anyone wants to help me with that, please contact me.

Regards,
Jeff Davis

Nothing else works seamlessly on Windows. :) But seriously, there is an
add-on you can get when you install PostgreSQL 8.3 on Windows that
contains an ancient implementation of Ruby and Rails -- with PostgreSQL,
of course. I looked at it briefly, and I have no idea how it was talking
to PostgreSQL.

At this stage of the game, I think a pure Ruby PostgreSQL (and MySQL)
interface has some serious advantages over struggling with numerous C
compilers for Windows, Mac, Solaris, etc.
 
P

Phillip Gawlowski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

M. Edward (Ed) Borasky wrote:

|
| At this stage of the game, I think a pure Ruby PostgreSQL (and MySQL)
| interface has some serious advantages over struggling with numerous C
| compilers for Windows, Mac, Solaris, etc.

No kidding. Looking at the ruby-installer ML, most of the difficulties
are with Ruby's *external* dependencies (readlines in particular).

And these issues cascade, for example, into PostgreSQL (some OpenSSL
dependency weirdness, I take it from Luis) in conjunction with Ruby.

Unfortunately, I don't know how one should implement pure Ruby
implementations since PostgreSQL and others would need to provide a Ruby
interface (at least, as far as I can see). Ah, the joy of interop..

On one level it sounds fun, on the actual implementation levels, I'm
getting greys hairs just looking at the matter.

Sadly, when it comes to C, I'm an end-user of provided binaries, as C
makes my head hurt just by reading C, so I can't be of much help to
Luis' efforts. :(

I have to get some C skills under my belt, methinks.

However, the OCI is making progress in switching away from VC6.0, though
progress is slow.


- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ - You know you've been hacking too long when...
...your friends who aren't hackers wonder what happened to you.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgFQzkACgkQbtAgaoJTgL/vJACeLzxjNj0qVlOKRpaP4w3/bFqI
pRoAn1byheOFdxwwUZN04amf+CrWLtw0
=m1rB
-----END PGP SIGNATURE-----
 
L

Luis Lavena

ruby-postgres had some serious maintenance problems, and was unable to
even build against PostgreSQL 8.3, and my various patches were not
applied.

So, I started maintaining a fork of ruby-postgres with my most important
patches applied, and started a rewrite to address some of the more
fundamental problems. The rewrite is called ruby-pg, and I consider it
to be the best driver available, and it's intended to replace the
others.


As far as I can tell, it's the only actively maintained PostgreSQL
driver for Ruby. It's fairly new, but:
* it's well documented (RDoc)
* offers almost all the functionality available from libpq (which is a
lot of functions)
* I'm responsive to bug reports
* I have an expanding set of rspec tests.

The biggest problem I am having with the project is making it work
seamlessly on windows. Several people have tried to help me, but I don't
think the problem has been solved, and I haven't received many specific
suggestions to make it work.

If anyone wants to help me with that, please contact me.

Jeff, I managed to get do_postgres (DataObject.rb project) working on
Windows with PostgreSQL 8.2.

Why you don't fill a Integration Request [1] at RubyInstaller tracker
and point with the instructions to get the code, the dependencies and
everything.

I'll be happy to provide patches to make it work properly under
Windows (both VC6 and MinGW). See my post on PostgreSQL [2]

[1] http://rubyforge.org/tracker/?atid=22895&group_id=167&func=browse
[2] http://rubyforge.org/pipermail/rubyinstaller-devel/2008-April/000284.html

Take care,
 
L

Luis Lavena

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

M. Edward (Ed) Borasky wrote:

|
| At this stage of the game, I think a pure Ruby PostgreSQL (and MySQL)
| interface has some serious advantages over struggling with numerous C
| compilers for Windows, Mac, Solaris, etc.

No kidding. Looking at the ruby-installer ML, most of the difficulties
are with Ruby's *external* dependencies (readlines in particular).

And these issues cascade, for example, into PostgreSQL (some OpenSSL
dependency weirdness, I take it from Luis) in conjunction with Ruby.

Unfortunately, I don't know how one should implement pure Ruby
implementations since PostgreSQL and others would need to provide a Ruby
interface (at least, as far as I can see). Ah, the joy of interop..

A pure ruby implementation involves:

Usage of Ruby/DL, which is a bridge between C API from DLL and Ruby
and lot of understanding of the internals of the adapter API.

Last time I used Ruby/DL was a nightmare since sometimes what
developers states they export quite differ from reality, so you ended
diggin into the utility source code to catch the expected result in
your side.

Lot of works, and still will be slower than a C ruby extension acting
as bridge between the DLL and your Ruby code.
Sadly, when it comes to C, I'm an end-user of provided binaries, as C
makes my head hurt just by reading C, so I can't be of much help to
Luis' efforts. :(

Don't worry, I take a lot of painkillers after staring a C function
for a long period of time...
I have to get some C skills under my belt, methinks.

However, the OCI is making progress in switching away from VC6.0, though
progress is slow.

I commented to Jeff he should ask for a Integration requrest and I can
help him get the adapter working on both implementations for the time
being.

Anyway, I'll love to know if Ruby on Rails will support this adapter
or not, since all the work will be useless if all the Railers came and
yell about their PostgreSQL database don't work for them :p

Regards,
 
M

M. Edward (Ed) Borasky

Luis said:
A pure ruby implementation involves:

Usage of Ruby/DL, which is a bridge between C API from DLL and Ruby
and lot of understanding of the internals of the adapter API.

Last time I used Ruby/DL was a nightmare since sometimes what
developers states they export quite differ from reality, so you ended
diggin into the utility source code to catch the expected result in
your side.

Lot of works, and still will be slower than a C ruby extension acting
as bridge between the DLL and your Ruby code.


Don't worry, I take a lot of painkillers after staring a C function
for a long period of time...


I commented to Jeff he should ask for a Integration requrest and I can
help him get the adapter working on both implementations for the time
being.

Anyway, I'll love to know if Ruby on Rails will support this adapter
or not, since all the work will be useless if all the Railers came and
yell about their PostgreSQL database don't work for them :p

Regards,

Speaking of Windows and seams, I discovered I have a spare genuine
Windows XP CD-ROM! I had forgotten that I bought it, so I have built a
Windows virtual machine from it snugly nestled inside my Linux
workstation. When I get my current (Linux and Ruby) project finished,
I'm planning to start testing the new One-Click. Meanwhile, I think I'm
going to put up the Windows PostgreSQL/Ruby/Rails thing and see if I can
get it to function in some kind of coherent manner, despite its age.
 
T

Tom Copeland

At this stage of the game, I think a pure Ruby PostgreSQL (and MySQL)
interface has some serious advantages over struggling with numerous C
compilers for Windows, Mac, Solaris, etc.

This may have already been mentioned, but there's postgres-pr:

======================
$ gem list -d --remote postgres-pr

*** REMOTE GEMS ***

postgres-pr (0.4.0)
A pure Ruby interface to the PostgreSQL (>= 7.4) database
======================

Yours,

tom
 
M

M. Edward (Ed) Borasky

M. Edward (Ed) Borasky said:
Speaking of Windows and seams, I discovered I have a spare genuine
Windows XP CD-ROM! I had forgotten that I bought it, so I have built a
Windows virtual machine from it snugly nestled inside my Linux
workstation. When I get my current (Linux and Ruby) project finished,
I'm planning to start testing the new One-Click. Meanwhile, I think I'm
going to put up the Windows PostgreSQL/Ruby/Rails thing and see if I can
get it to function in some kind of coherent manner, despite its age.

Well ... don't say I didn't try. :) I installed PostgreSQL 8.3 and the
Rails add-on that comes from a third party. I was not able to get it to
function, however. What I know so far is that it is derived from the
One-Click Installer version 186-22. However, it installs in C:\pgRails,
but all of the "bat" files from the One-Click still are looking for
C:\Ruby, and it doesn't put the right path in the PATH environment
variable. So the "gem" console, which is usually how I access things
from the One-Click Ruby, doesn't work.

The Rails piece of it may be hard coded to actually function, but I
couldn't find any documentation on how to start that up, so I didn't get
anywhere with it. A couple of months ago I tried it and posted some
comments on the creator's forum. They are looking for volunteers. :)

By the way, if it matters, the Windows PostgreSQL 8.3 installer loads a
copy of the Visual C++ 2005 run time.
 
T

Thomas Kellerer

Phillip Gawlowski, 16.04.2008 02:08:
Unfortunately, I don't know how one should implement pure Ruby
implementations since PostgreSQL and others would need to provide a Ruby
interface (at least, as far as I can see).

The Postgres JDBC driver is 100% Java and definitely does not rely on any external DLLs or libraries, it speaks the native PG protocol (AFAIK there is no such thing as a "Java interface").
So why shouldn't this be possible with Ruby as well?

Thomas
 
P

Phillip Gawlowski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thomas Kellerer wrote:

| The Postgres JDBC driver is 100% Java and definitely does not rely on
| any external DLLs or libraries, it speaks the native PG protocol (AFAIK
| there is no such thing as a "Java interface"). So why shouldn't this be
| possible with Ruby as well?

Because Ruby doesn't really compare to Java in terms of infrastructure
and APIs?

Both Ruby and the database you want to speak to have to provide an API
to do that (JDBC is a Java API, and still needs the proper connectors to
actually talk to the database, similar to ODBC).

It is not yet possible with Ruby (except via Ruby/DL, I've heard), but
it certainly could be.

So, up to trying to do something like that? ;P

At the moment, you have to hook into C somehow, or wrap a C/C++
extension to pull that off. Which is certainly possible, as the various
DB-gems show.

However, since Ruby has no ready-made API for hooking up DB connectors
and all that stuff, the job has be done over and over again, for each DB
Ruby shall support.

And, IMO, adding such an API, while nice, would be beyond Ruby's scope.

And JRuby needs the JDBC libraries of, for example, MySQL to talk to a
MySQL server. Those aren't part of Java's distribution. :|

But the relative ease of installation makes JRuby very, very attractive
to me when deploying Rails apps.

Well, MySQL might become shipped as a standard, since Sun bought out
MySQL, but you never know..


Long story short: It's not impossible to define a standard API for Ruby,
but somebody has to do it yet (don't look at me, C makes me scream).


- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ - You know you've been hacking too long when...
...you want to retract something said in haste, and think C-a C-@ C-e C-w
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgGD48ACgkQbtAgaoJTgL+OmQCfbLO5l8x0cw+HhH8C6RClJ7VR
SWkAmwX2UxbzdJgNM25SOhEuB+OWDeC1
=4UzI
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,134
Latest member
Lou6777736
Top