Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Perl, Postgres and Windows

by rhj4 (Initiate)
on Jan 18, 2011 at 00:44 UTC ( #882784=perlquestion: print w/ replies, xml ) Need Help??
rhj4 has asked for the wisdom of the Perl Monks concerning the following question:

I am a C#/SQL Server programmer tasked with converting an ancient Perl/Posgtres website into C#. I have been programming for many years and in many languages, but never in Perl and I am having some challenges getting started.

I have downloaded and installed Postgresql 9.0 on my desktop and populated it with data from the production site which is on a machine that could die any day. I have written some test code in C# using Npgsql that successfully accesses data in that database, but I have encountered problems using PGAdmin III and psql. Both appear flakey or improperly configured (highly likely).

I have installed ActiveState 6.0.3 and Strawberry Perl and I am attempting to get started, but hit a wall quickly. The code below fails on the “use Pg;” line. I have located several versions of this file, but none that seems to meet the approval of the compiler. I think the problem involves four variables:

  • Version of ActiveState Komodo product (6.0.3)
  • Version of Perl compiler (perl 5, version 12, subversion 2 (V5.12.2) built for MSWin32-x64-multi-thread, according to command line “perl –v”)
  • Version of Postgresql (9.0)
  • Version of Pg.pm ???

Can you tell me what version of Pg I should install and where to put it in the code base?

#!/usr/bin/perl
require "PAQ.cfg";
require "PAQ_include.pl";
use CGI qw(:standard);
use Pg; <-- FAILS HERE - CANNOT LOCATE FILE

$q = new CGI;

Comment on Perl, Postgres and Windows
Re: Perl, Postgres and Windows
by syphilis (Canon) on Jan 18, 2011 at 01:12 UTC
    You don't mention what perl version you have, but the following are available via ppm for perl-5.12, either from the ActiveState repo, or the trouchelle repo (or, in some cases, both):

    DBD::PgPP, Pg::CLI, Pg::Explain, Pg::Loader, Pg::Priv.

    I don't know anything about Postgres, but I would think that it's the first in that list that gives you the driver you need. So, start with:
    ppm install DBD-PgPP
    and then 'ppm install' the others if they might also be useful.

    Cheers,
    Rob
Re: Perl, Postgres and Windows
by stefbv (Chaplain) on Jan 18, 2011 at 10:17 UTC

    DBD::PgPP is the "Pure Perl" PostgreSQL driver, to be used when is no other choice, better use DBD::Pg, which is installed by default in ActiveState Perl 5.12.2 build 1203, and in Strawberry Perl.

    Regards, Stefan

Re: Perl, Postgres and Windows
by Limbic~Region (Chancellor) on Jan 18, 2011 at 16:35 UTC
    rhj4,
    I have successfully used Pg and PGAdmin on various different windows for a couple of years without issue. I also have never used Pg - it was last updated 11 years ago. I don't know what issue you are having with PGAdmin but I am quite sure your issue with your code are that you are not using DBD::Pg. I don't want to knock C# but my guess is that if the project had been kept up to date, it would probably not be necessary to migrate now.

    Cheers - L~R

      Original developer could not keep up with code. He died. Company sold, and years later, I inherit the problem. I am still facing newbie-itis with perl. I have no difficulty with strongly typed languages, but others like perl and JavaScript give me headaches. The issue with PGAdmin III is that when I click the SQL button, the program locks up tight. No way out. Have to kill it and restart. Gives me lots of confidence in the code...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://882784]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-10-25 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls