Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

runrig (3385)

runrig
  dougwNO@SPAMcpan.org

Just another perl hacker somewhere near Disneyland

I have this homenode [perlmonks.org] of little consequence on Perl Monks [perlmonks.org] that you probably have no interest in whatsoever.

I also have some modules [cpan.org] on CPAN [cpan.org] some of which are marginally [cpan.org] more [cpan.org] useful [cpan.org] than others.

Journal of runrig (3385)

Saturday May 29, 2004
09:06 PM

Getting started on PostgreSQL

[ #19002 ]

I'm not real interested yet in database tuning, I just wanted to get a database up and running.

You'd think reading the "Getting Started" section of the docs would get you started. At least there are a bunch of docs installed in the postgresql/doc directory. Except "Getting Started" assumes that the server is ready to go. It starts with creating a database, and says if you get this error it means the server was not started or not installed, go talk to the administrator.

So after talking to myself, I understand it's a client/server database, and I have to start the server, so how do I do that? A bit of searching the docs and I find that you have to run "postmaster" or the shell script shortcut to it "pg_ctl", and that it seems a good idea to set the PGDATA environment variable to where your databases will be, so I run "pg_ctl start -l logfile" ("logfile" is created in the current directory) like the docs say, except this is Windows so I have to say "sh pg_ctl start -l logfile" (they should name the shell scripts *.sh when installing on Windows, and associate ".sh" files with "sh.exe". File extensions are annoying on Unix but a necessary evil on Windows. Or they (a different "they") should make shebang lines work in Windows). Except I get errors about files not existing in the data directory, and just as I think "there must be some easy way to create all these files in the data directory", I find that you need to first run "initdb" which does just that :)

Then I can create a database with 'createdb', and test a bit with the console app 'psql' to see that I can create a table, insert, and select.

So then I install DBD::Pg, and don't have much luck getting it to work, so I install DBD::PgPP, and it doesn't work either, until I look at the PgPP code and think "so what happens if I add ';host=localhost' to the connect string" (even though that's supposed to be the default, but I see that adding that does something different), and find that works, and that it works for DBD::Pg also.

Except after all this, the DBI statement handle attributes NAME and TYPE still don't work, which is the main reason that I installed Postgres (along with it being free), and just as I contemplate trying to add those features, I think of installing the PostgreSQL ODBC driver. So I install it and DBD::ODBC, create a file dsn, copy the contents to the DBI connect string (because I don't like using DSN's if I don't have to), and everything (and I mean everything) just works. Joy. :-)

Update: and 'sh pg_ctl stop' doesn't work, it tries to kill a pid contained in a '.pid' file in the data directory, except that it's the wrong pid. Killing the correct pid leaves the '.pid' file and makes postgres think it's still running next time you start up, and then manually removing the '.pid' file makes postgres go through some cleanup to restart. I'm not sure if there's any clean way to shut down on Windows. Probably all due to the lack of unix-like signals maybe???

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.