[ANN] postgres-pr (pure Ruby PostgreSQL)

M

Michael Neumann

Hi,

I'm proud to announce the first public "release" of postgres-pr. This is
a library to access PostgreSQL from Ruby without the need of any C
library.

* You can use it only with newer 7.x databases that use wire-protocol 3.
* Lot's of stuff is missing, only the wire-protocol is quite complete.

Quick Example:
gem install postgres-pr
irb -r rubygems

Then in the interactive Ruby interpreter type (replace DBNAME and DBUSER
accordingly):

require 'postgres-pr/connection'
c = Connection.new('DBNAME', 'DBUSER')
c.query('SELECT 1+2') # => [["3"]]

Regards,

Michael
 
D

David Ross

Michael said:
Hi,

I'm proud to announce the first public "release" of postgres-pr. This
is a library to access PostgreSQL from Ruby without the need of any C
library.

* You can use it only with newer 7.x databases that use wire-protocol 3.
* Lot's of stuff is missing, only the wire-protocol is quite complete.

Quick Example:
gem install postgres-pr
irb -r rubygems

Then in the interactive Ruby interpreter type (replace DBNAME and DBUSER
accordingly):

require 'postgres-pr/connection'
c = Connection.new('DBNAME', 'DBUSER')
c.query('SELECT 1+2') # => [["3"]]

Regards,

Michael
oh neato. I'm glad someone made a pure ruby version.

Is there an rpa?

David Ross
 
M

Michael Neumann

David said:
Michael said:
Hi,

I'm proud to announce the first public "release" of postgres-pr. This
is a library to access PostgreSQL from Ruby without the need of any C
library.

* You can use it only with newer 7.x databases that use wire-protocol 3.
* Lot's of stuff is missing, only the wire-protocol is quite complete.

Quick Example:
gem install postgres-pr
irb -r rubygems

Then in the interactive Ruby interpreter type (replace DBNAME and DBUSER
accordingly):

require 'postgres-pr/connection'
c = Connection.new('DBNAME', 'DBUSER')
c.query('SELECT 1+2') # => [["3"]]

Regards,

Michael
oh neato. I'm glad someone made a pure ruby version.

Is there an rpa?

nope. maybe later, if it's better tested.

Regards,

Michael
 
D

David Ross

Michael said:
David said:
Michael said:
Hi,

I'm proud to announce the first public "release" of postgres-pr.
This is a library to access PostgreSQL from Ruby without the need of
any C
library.

* You can use it only with newer 7.x databases that use
wire-protocol 3.
* Lot's of stuff is missing, only the wire-protocol is quite complete.

Quick Example:

gem install postgres-pr
irb -r rubygems

Then in the interactive Ruby interpreter type (replace DBNAME and
DBUSER
accordingly):

require 'postgres-pr/connection'
c = Connection.new('DBNAME', 'DBUSER')
c.query('SELECT 1+2') # => [["3"]]

Regards,

Michael
oh neato. I'm glad someone made a pure ruby version.

Is there an rpa?


nope. maybe later, if it's better tested.

Regards,

Michael
Maybe I'll throw it together then for batsman, I *love* postgres with a
passion, and was going to use postgres as a backend for my project. I'm
glad theres a pure ruby version, people hate compiling. Thanks a kilo
Neumann

Ross
 
M

Michael Neumann

David said:
Maybe I'll throw it together then for batsman, I *love* postgres with a
passion, and was going to use postgres as a backend for my project. I'm
glad theres a pure ruby version, people hate compiling. Thanks a kilo
Neumann

btw, I quickly hacked up a compat-library, so that you can use the
postgres-ActiveRecord adaptor. It thinks, it uses the C version of
postgres (and indeed loads it if it's available).

I was to lazy to rewrite the whole adaptor...

Regards,

Michael
 
M

Michael Neumann

Michael said:
btw, I quickly hacked up a compat-library, so that you can use the
postgres-ActiveRecord adaptor. It thinks, it uses the C version of
postgres (and indeed loads it if it's available).

it's now available as postgres-pr version 0.1.0. If you've installed
this and ActiveRecord, it should work out-of-the-box.

Regards,

Michael
 
S

Scott Barron

Michael Neumann wrote:

it's now available as postgres-pr version 0.1.0. If you've installed
this and ActiveRecord, it should work out-of-the-box.

Regards,

Michael

Michael,

Very sweet! I'm playing with it and I've hit a few points of
incompatibility so far.

First up, AR will allow you to leave out the host for the postgresql adapter,
which effectively tells the postgres module to use the unix socket. Your
library seems to require it to be set to /dir for the directory the socket file
resides in. I rather prefer your method, but any existing Rails apps would
have to change.

Next, AR is expecting that PGResult have []. Mapping this to
@rows.res seems to fix the problem.

Next, your library doesn't seem to like integers that are quoted (eg
UPDATE foo set bar='' where id='1') and this makes a number of AR's
unit tests fail.

Finally, I haven't tracked down this problem just yet, but the AR unit
tests give a good deal of errors very similar to this one:

test_create(BasicsTest):
NoMethodError: undefined method `title=' for #<Topic:0x1027888
@attributes={}, @new_record=true>
./test/../lib/active_record/base.rb:817:in `method_missing'
./test/base_test.rb:108:in `test_create'

Where it is always failing on a method foo= for an AR class.

Using my own project, postgres-pr works out of the box, but the real
test seems to be making the AR unit tests pass. I'm really glad you
started this project, a gemmed, pure ruby postgres adapter will make
my life easier in a number of ways. Thanks!

-Scott
 
T

Tom Copeland

I'm really glad you
started this project, a gemmed, pure ruby postgres adapter will make
my life easier in a number of ways. Thanks!

Let me add my thanks, too. I can see this library getting lots of heavy
usage for my Ruby scripts for admin'ing RubyForge; currently I'm doing
things like exec'ing "psql -c" :)

Thanks,

Tom
 
M

Michael Neumann

--------------030708020500080209070409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Scott said:
Michael Neumann wrote:

it's now available as postgres-pr version 0.1.0. If you've installed
this and ActiveRecord, it should work out-of-the-box.

Regards,

Michael


Michael,

Very sweet! I'm playing with it and I've hit a few points of
incompatibility so far.

First up, AR will allow you to leave out the host for the postgresql adapter,
which effectively tells the postgres module to use the unix socket. Your
library seems to require it to be set to /dir for the directory the socket file
resides in. I rather prefer your method, but any existing Rails apps would
have to change.
fixed!

Next, AR is expecting that PGResult have []. Mapping this to
@rows.res seems to fix the problem.
fixed!

Next, your library doesn't seem to like integers that are quoted (eg
UPDATE foo set bar='' where id='1') and this makes a number of AR's
unit tests fail.
fixed!

Finally, I haven't tracked down this problem just yet, but the AR unit
tests give a good deal of errors very similar to this one:

test_create(BasicsTest):
NoMethodError: undefined method `title=' for #<Topic:0x1027888
@attributes={}, @new_record=true>
./test/../lib/active_record/base.rb:817:in `method_missing'
./test/base_test.rb:108:in `test_create'

Where it is always failing on a method foo= for an AR class.

I've run the test cases. of the 717 assertions, I get only 10 errors,
but they seem to be not postgres-pr specific. I've appended the output
of the test-cases at this email. Maybe someone can take a look at it.

I've released 0.1.1 which fixes all those bugs (except the remaining
10). Update the gem and run the test-cases.

Regards,

Michael

--------------030708020500080209070409
Content-Type: text/plain;
name="postgres-pr-tests"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="postgres-pr-tests"

Using native PostgreSQL
Loaded suite -e
Started
........................................................................................................................................................................................................................EEEEEEEEEE.................
Finished in 9.688505 seconds.

1) Error:
test_string_key(PrimaryKeysTest):
RuntimeError: #<ErrorResponse:0x8510570 @field_type=83, @field_values=["ERROR", "C42P01", "Mrelation \"subscribers_nick_seq\" does not exist", "Fnamespace.c", "L193", "RRangeVarGetRelid"]>
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres-pr/connection.rb:81:in `query'
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres-pr/connection.rb:66:in `loop'
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres-pr/connection.rb:66:in `query'
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres-pr/connection.rb:61:in `synchronize'
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres-pr/connection.rb:61:in `query'
/home/mneumann/Programs/usr/lib/ruby/gems/1.8/gems/postgres-pr-0.1.0/lib/postgres.rb:30:in `exec'
./../lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `last_insert_id'
./../lib/active_record/connection_adapters/postgresql_adapter.rb:60:in `insert'
./../lib/active_record/base.rb:776:in `create_without_callbacks'
./../lib/active_record/callbacks.rb:235:in `create'
./../lib/active_record/base.rb:761:in `create_or_update_without_callbacks'
./../lib/active_record/callbacks.rb:224:in `create_or_update'
./../lib/active_record/base.rb:647:in `save_without_validation'
./../lib/active_record/validations.rb:55:in `save_without_transactions'
./../lib/active_record/transactions.rb:115:in `save'
./../lib/active_record/transactions.rb:115:in `transaction'
./../lib/active_record/transactions.rb:86:in `transaction'
./../lib/active_record/transactions.rb:100:in `transaction'
./../lib/active_record/transactions.rb:115:in `save'
./pk_test.rb:37:in `test_string_key'

2) Error:
test_aggregation_reflection(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

3) Error:
test_association_reflection(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

4) Error:
test_association_reflection_in_modules(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

5) Error:
test_column_string_type_and_limit(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

6) Error:
test_columns(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

7) Error:
test_content_columns(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

8) Error:
test_human_name_for_column(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

9) Error:
test_integer_columns(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

10) Error:
test_read_attribute_names(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

243 tests, 717 assertions, 0 failures, 10 errors

--------------030708020500080209070409--
 
S

Scott Barron

fixed!
fixed!
fixed!
Outstanding!

I've run the test cases. of the 717 assertions, I get only 10 errors,
but they seem to be not postgres-pr specific. I've appended the output
of the test-cases at this email. Maybe someone can take a look at it.

I've released 0.1.1 which fixes all those bugs (except the remaining
10). Update the gem and run the test-cases.

I just updated to 0.1.1 and ran the tests from AR CVS and they all
passed (well, see below).
1) Error:
test_string_key(PrimaryKeysTest):
RuntimeError: #<ErrorResponse:0x8510570 @field_type=83, @field_values=["ERROR", "C42P01", "Mrelation \"subscribers_nick_seq\" does not exist", "Fnamespace.c", "L193", "RRangeVarGetRelid"]>

... This one I still get but I believe it is a bug in the tests, not
your library (it happens with the C postgres extension as well). It
seems AR is looking for an auto increment sequence on a table using a
text primary key. Haven't looked at it much futher yet.
2) Error:
test_aggregation_reflection(ReflectionTest):
ActiveRecord::RecordNotFound: Couldn't find Topic with ID = 1
./../lib/active_record/base.rb:242:in `find'
./reflection_test.rb:13:in `setup_without_fixtures'
./../lib/active_record/fixtures.rb:242:in `setup'
./../lib/active_record/fixtures.rb:240:in `setup'

I was getting these with 0.1.0 but now I'm not with 0.1.1. They seem
to be working now. This rocks out loud.

-Scott
 
D

David Garamond

David said:
Michael Neumann wrote:
oh neato. I'm glad someone made a pure ruby version.

ditto here. a wonderful news. i think i'm going to try to use it on a
regular basis instead of the "postgres" C-based library, solely because
only postgres-pr is available as a gem (yes, i'm that lazy :). i use
ruby on lots of machines...
Is there an rpa?

i thought the purpose of RPA is as a collection of _production_-level
(mostly mature, stable, well tested) libraries?
 
G

George Moschovitis

I'm proud to announce the first public "release" of postgres-pr. This is
a library to access PostgreSQL from Ruby without the need of any C
library.

Just excellent! Thanks a lot :) Lets hope that more people will start
using PostgreSQL instead of mySQL.

George.
 
M

Mauricio Fernández

ditto here. a wonderful news. i think i'm going to try to use it on a
regular basis instead of the "postgres" C-based library, solely because
only postgres-pr is available as a gem (yes, i'm that lazy :). i use
ruby on lots of machines...


i thought the purpose of RPA is as a collection of _production_-level
(mostly mature, stable, well tested) libraries?

That is the primary goal of RPA, but it doesn't exclude packaging more
libraries; in fact, some 150 libraries/applications have been packaged
so far, and many are not "production-level".
Quoting from http://rpa-base.rubyforge.org/wiki/wiki.cgi?Rpa_FAQ :

Will there be a repository for experimental packages or will all packages
need to fit the production requirements?

A (small) part of RPA will be declared suitable for production use
(i.e. mature, documented, tested). However, third party software that is
not ready for production will be packaged too, in a separate section of
the repository. You can compare that broadly to Debian's sections: there
will be a "production" section and another bigger one with everything else
(we have yet to decide on the names).

In other words, the requirements for "production quality" will be met by
the software declared production-ready by RPA (this will be a section
within RPA). Those requirements do not determine whether some software
will be packaged by RPA or not. Clearly, high quality software is more
likely to be packaged in RPA, but given enough resources (esp. manpower)
RPA could repackage most of the software currently listed in RAA.
 
D

David Garamond

Mauricio said:
That is the primary goal of RPA, but it doesn't exclude packaging more
libraries; in fact, some 150 libraries/applications have been packaged
so far, and many are not "production-level".
Quoting from http://rpa-base.rubyforge.org/wiki/wiki.cgi?Rpa_FAQ :

I see. Thanks for the clear-up. Haven't had a chance to play with RPA.

So which between rubygems and RPA is more popular? Is there any
indication of which one will be the "official" or "preferred" packaging
system for Ruby in the future? Which one will become (or will be the
closest to) the Ruby equivalent of CPAN? By that I mean I can find and
install most Ruby libraries with it.

Ruby library writers, which one do you prefer or do you find easier to
package your software with?

Regards,
dave
 
M

Michael Neumann

George said:
Just excellent! Thanks a lot :) Lets hope that more people will start
using PostgreSQL instead of mySQL.

I'm looking forward to use postgres-pr with Og ;-)

Regards,

Michael
 
M

Mauricio Fernández

I see. Thanks for the clear-up. Haven't had a chance to play with RPA.

So which between rubygems and RPA is more popular?

RubyGems is more popular. The RubyGems team have made a great effort to
document and establish it as the Ruby standard for upstream releases.
Is there any indication of which one will be the "official" or
"preferred" packaging system for Ruby in the future?

One doesn't preclude the other. RubyGems' goal is expressed by its
RubyForge description:
"RubyGems is the Ruby standard for publishing and managing third party
libraries."
(AFAIK there is no other mission statement or declaration of purposes)
In other words, RubyGems should become the preferred system for upstream
releases. This is fine because the RubyGems team have often expressed
their commitment to making RubyGems packages easy to repackage, so
hopefully it will improve the current situation; this hasn't happened
yet but RubyGems is still young.

The goals of RPA are expressed in our manifesto:
http://rpa-base.rubyforge.org/wiki/wiki.cgi?RpaManifesto
The RPA project is larger and more ambitious than RubyGems; it's not
primarily about making other people package using our technology, but
about having the RPA packager team create and maintain the packages.

The analogy would be automake/autoconf vs. FreeBSD.

RPA happens to use its own packaging technology (rpa-base) because
RubyGems' one doesn't satisfy our requirements and there is some gain
in being able to change simultaneously the port/package manager and the
ports/packages. You can find more information about rpa-base and its
features at http://rpa-base.rubyforge.org/ .
Which one will become (or will be the closest to) the Ruby equivalent
of CPAN? By that I mean I can find and install most Ruby libraries
with it.

Currently, there are more libraries/applications packaged in RPA than in
RubyGems' repository. This should change eventually, since mere package
count is not a goal in itself for RPA: the fact that it still has more
packages than RubyGems' repository is a rather anomalous situation.

Note that neither RubyGems nor RPA try to mimic CPAN. In the case of RPA,
the main sources of inspiration are FreeBSD and Debian. However the idea
of having a repository is more central to RPA than to RubyGems: after
all, it's the Ruby Production *Archive*.
Ruby library writers, which one do you prefer or do you find easier to
package your software with?

In general, they should package using RubyGems or Aoki's setup.rb.
RPA packages are created by the RPA crew: the upstream developer needs
not do anything.

So the comparison would be creating the gemspec vs. doing nothing ;-)

If you're interested in RPA or its technology, feel free to join #RPA
at irc.freenode.net. A typical "rpafied install.rb" (most often the only
thing you need to create a RPA port) looks like


require 'rpa/install'

class Install_rcov < RPA::Install::FullInstaller
name "rcov"
version "0.0.2-2"
classification Application.Devel
description <<EOF
RPA's code coverage info and profiling overview generator

rcov allows the developer to identify unused regions of code. It is
especially useful when combined with unit tests, since it will indicate
which areas of the code can't possibly have been tested.

rcov can also gather some basic profiling information (how often a line
of code is run), allowing to locate the hotspots visually.
EOF
end
 
C

Chad Fowler

I see. Thanks for the clear-up. Haven't had a chance to play with RPA.

So which between rubygems and RPA is more popular? Is there any
indication of which one will be the "official" or "preferred" packaging
system for Ruby in the future? Which one will become (or will be the
closest to) the Ruby equivalent of CPAN? By that I mean I can find and
install most Ruby libraries with it.

Ruby library writers, which one do you prefer or do you find easier to
package your software with?


I'm going to attempt to nip this one in the bud being that this will
have been the Nth (N being higher than 2) RubyGems vs. RPA thread on
ruby-talk. RubyGems and RPA are NOT an either/or question. RPA is
not a package manager. rpa-base is a package manager, with it's
primary goal being to support the needs of RPA.

RubyGems is only a package manager. Its goal is to become the
official package manager for Ruby libraries and applications. Most
gems are created by the original authors of these libraries or
applications. Most RPA packages are created by Mauricio Fernandez
(repackaged). RPA will eventually be QA'd by a team of people.
RubyGems are (officially) unpoliced--bazaar-style distribution (though
it would be possible to create a QA'd repository of gems, that's not
on our radar screen at the moment).

Ideally, RPA-ification of libraries will lead to RubyGems-friendliness
and vice versa.

--

Chad Fowler
http://chadfowler.com
http://rubycentral.org
http://rubygarden.org
http://rubygems.rubyforge.org (over 20,000 gems served!)
 
G

George Moschovitis

I'm looking forward to use postgres-pr with Og ;-)

You can count on that :)

I 'll include postgres-pr support in the stand-alone Og
distribution (next week).

regards,
George
 
A

Abraham Vionas

OH NO, you realize you're opening the proverbial can of worms, right? Last
time (if I recall correctly) things ended up with Gems vs. RPA'ers and at
each others throats.

Personally, I believe some of my recent difficulties getting a Rails
tutorial to work may be because I installed both RPA and Gems and then
allowed RPA to take ownership of Rails... I've also noticed that RPA will
redownload and install any dependencies for it's packages even if they
already exist on the users machine.

Regards, Abe

P.s. I like both methods. One thing that RPA has that Gems doesn't is the
ability to list (with a single line summary) all of the packages available
for download and install through RPA. While I understand that there's a lot
of methology differences between the two camps, from a user perspective both
seem to accomplish the same thing and do so very well.



-----Original Message-----
From: David Garamond [mailto:[email protected]]
Sent: Friday, November 19, 2004 4:55 AM
To: ruby-talk ML
Subject: RPA vs rubygems (Re: [ANN] postgres-pr (pure Ruby PostgreSQL))
That is the primary goal of RPA, but it doesn't exclude packaging more
libraries; in fact, some 150 libraries/applications have been packaged
so far, and many are not "production-level".
Quoting from http://rpa-base.rubyforge.org/wiki/wiki.cgi?Rpa_FAQ :

I see. Thanks for the clear-up. Haven't had a chance to play with RPA.

So which between rubygems and RPA is more popular? Is there any indication
of which one will be the "official" or "preferred" packaging system for
Ruby in the future? Which one will become (or will be the closest to) the
Ruby equivalent of CPAN? By that I mean I can find and install most Ruby
libraries with it.

Ruby library writers, which one do you prefer or do you find easier to
package your software with?

Regards,
dave
 
T

Tobias Luetke

P.s. I like both methods. One thing that RPA has that Gems doesn't is the
ability to list (with a single line summary) all of the packages available
for download and install through RPA. While I understand that there's a lot
of methology differences between the two camps, from a user perspective both
seem to accomplish the same thing and do so very well.

???
try: gem list -r
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top