Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thank you Corion for pointing me in the right direction. I have finally solved the problem which was a combination of lack of PostgreSQL ODBC driver and improper format of connection string.

Solution

Remark: I recommend using DBD::ODBC to connect to PostgreSQL on Windows instead of DBD::PgPP (unmaintained and full of bugs, written in Pure Perl) or DBD::Pg (no Windows version on ppm & latest update on http://pgfoundry.org/frs/?group_id=1000199&release_id=1212 is for Perl 5.10 made in late 2008).
1. Install latest version of DBI & DBD-ODBC using ppm.
2. Download & install appropriate psqlodbc driver from http://www.postgresql.org/ftp/odbc/versions/msi/ (don't forget to upgrade using the batch file).
3. Go to Control Panel -> Administrative Tools. Choose Data Sources shortcut. In the ODBC Data Source Administrator dialog box, click Add, then select the driver (e.g.: PostgreSQL Unicode) you want from the Installed ODBC Drivers list and choose OK.
4. Use the appropriate connection string (http://connectionstrings.com/postgre-sql#p51), e.g.:

my $dbh = DBI->connect("dbi:ODBC:driver={PostgreSQL Unicode};Server=12 +7.0.0.1;Port=5432;Database=database;Uid=username;Pwd=password;", user +name, password, {PrintError => 1, RaiseError => 1}) || die "Error $DB +I::err [$DBI::errstr]";
5. Using telepathy, thank the person who compiled this little manual for you so that you don't have to go through the cycle of frustration, disillusionment and apathy.


In reply to Re: Cannot connect Perl to PostgreSQL using ODBC (SQL-IM002) by lr3p
in thread Cannot connect Perl to PostgreSQL using ODBC (SQL-IM002) by lr3p

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found