Strawberry Perl, by default, does not include many Database Drivers. While it does a great job installing most modules, some CPAN authors simply overlooked Win32 as a target platform, so the build/installation scripts get confused. Among these is the DBD::Pg driver (PostgreSQL database driver), which is really just a thin layer providing access to the C library, libpq.
In terms of working with PostgreSQL databases under Windows, this effectively leaves people with a few options:
- Try to install the Perl Package Manager (ppm) version of DBD-Pg. This didn’t work for me. I suppose that’s because the installer was expecting an ActivePerl-like environment, and I was using Strawberry Perl’s ppm tool.
- Compile the DBD::Pg drivers from scratch using Microsoft Visual Studio. This wasn’t a possibility for me because I don’t want to purchase Visual Studio. My school provides licenses via the MSDN Academic Alliance, but I wanted to use something more open-source if possible. Also, the Visual Studio suite is pretty large and takes a significant amount of time to install. It also clutters your machine with an SQL database, among other things.
- Install DBD::PgPP, a Pure Perl version of the PostgreSQL API. The problem with this is that there are lots of outstanding bugs, and so far it does not behave in exactly the same way as DBD::Pg.
- Install a specialized Perl package like Camelbox (one of Camelbox’s design goals was to provide DBI and popular DBD support out of the box). I didn’t like the idea of this because I’m so far a pretty big fan of Strawberry Perl and its sister project, Vanilla Perl. Together they seem like the most effective way to solve the Perl-on-Win32 dilemma.
As it turns out, there’s another option. Taking the package stuff meant for Camelbox and dropping it into your Strawberry Perl installation. It works flawlessly, and I’m very grateful to Brian Manning for his work on the project.
Here’s the quick and dirty:
- Download the postgresql-bin package from the Camelbox downloads area.
- Download the perl-DBD-Pg package from the same place.
- Open the lzma files using your favourite archiver program. I love 7-zip and it worked beautifully for extracting those files.
- Under the perl-DBD-Pg package, there should be a bunch of subdirectories; these correspond to those under C:\Strawberry\perl (or the perl subdirectory of wherever you installed Strawberry Perl). Extract all the files there.
- In the postgresql-bin package, there is a bin directory that contains a single file, libpq.dll. This one is really important for connecting to the database as it does all of the real work; the Perl stuff just binds to the library functions. Extract this one into C:\Strawberry\perl\site\lib\auto\DBD\Pg (or wherever your Pg.dll is installed)
Alternatively, it might be less stressful to just install Camelbox instead of Strawberry Perl; but this is entirely up to you.