dargosch has asked for the wisdom of the Perl Monks concerning the following question:

Dear fellow monks,

I'm researching the proper tools to use for an application that gathers data and inserts it into a PostgreSQL database with ODBC extensions. Now, the question I am asking is which one of the different Perl <-> PostgreSQL modules available on CPAN is worth investigating further.

The modules I've found so far is "Postgres", "Pg" and "PgSQL" as well as a reference to a DBI::Pg in one of the threads on site (is that the same as "Pg"?).

So, which one would the monks of this monastery recommend?

/Dargosch
  • Comment on Recommendations on module for Perl <-> PostgreSQL interaction

Replies are listed 'Best First'.
Re: Recommendations on module for Perl <-> PostgreSQL interaction
by gmax (Abbot) on Jun 25, 2003 at 12:09 UTC
    Your best shot should be DBD::pg for normal use. It is a module dependant on the DBI and it would allow you to apply some general knowledge to your specific problem. Meaning that, once you learn how to use Postgres from the DBI, you can also use whichever other database without much effort.

    An alternative, useful in cases when you can't install the Postrgres client, is DBD:PgPP. From its docs:
    DBD::PgPP is a Pure Perl client interface for the PostgreSQL database. This module implements network protocol between server and client of PostgreSQL, thus you don't need external PostgreSQL client library like libpq for this module to work. It means this module enables you to connect to PostgreSQL server from some operation systems which PostgreSQL is not ported.

    Finally, there is DBD::ODBC, which will access your database through the ODBC interface. Be aware that, while this is a generalized approach that will smooth the differences between databases, it will aslo pre-process your queries, adding some overhead that in several cases can account to up to 20-30% of your performance.

    Pg and PgSQL haven't been updated for years, and I would not start with them.

    _ _ _ _ (_|| | |(_|>< _|

      You wouldn't start with Pg but it can be a destination. DBD::Pg suffers by having to read the entire result set into memory before using it. Pg can perform both asynchronous queries and has support for cursors. If you're dealing with large data sets then DBD::Pg may just be entirely inappropriate. There's a Pg::Smart or something named like that that picks up where Pg left off and is more DBI-like except with all the good bits.

Re: Recommendations on module for Perl <-> PostgreSQL interaction
by zby (Vicar) on Jun 25, 2003 at 10:02 UTC
    Just for assurance - are you going to use PostgreSQL as ODBC data source? Since ODBC is a abstraction layer you don't use PostgreSQL specific libraries with it. You just use DBD::ODBC.
      Acctually, I have hade a real problem installing that module (DBD::ODBC). It seems that it cannot find my unixODBC installation even though I've set the recommended environment variable. DBD::Pg seems to work though..

      Thanks anyway for the recommendation!

      /Dargosch
        It was not a recommendation - it was a clarification. I don't recommend using ODBC over DBD::Pg or some other library. I just seemed to me that you need to use ODBC - and I explained that in that case you don't need DBD::Pg. Actually I would rather not use ODBC when I can - I like the DBD abstraction.
Re: Recommendations on module for Perl <-> PostgreSQL interaction
by mpeppler (Vicar) on Jun 25, 2003 at 11:27 UTC
    I don't know much about PostgreSQL, but I'd start with DBI and DBD::Pg.

    Michael