pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is there something wrong with Perl's dbi and PostgreSQL?
2+ messages / 2 participants
[nested] [flat]

* Is there something wrong with Perl's dbi and PostgreSQL?
@ 2003-09-29 17:51 Jeff Self <jself@nngov.com>
  2003-09-29 18:45 ` Re: Is there something wrong with Perl`s dbi and PostgreSQL? greg@turnstep.com
  0 siblings, 1 reply; 2+ messages in thread

From: Jeff Self @ 2003-09-29 17:51 UTC (permalink / raw)
  To: pgsql-sql

I just tried running a perl script that I wrote about a year ago. It had
worked for me in the past. Now it doesn't work. I can view data from a
table, but I am unable to either drop a table or create a table. I'm
running PostgreSQL 7.3.4 and DBI 1.35 along with Perl 5.8.1.

Here's my script for creating a table:
#!/usr/bin/perl -w
# createfoo.pl

use strict;
use DBI;

my $dbh = DBI->connect( 'dbi:Pg:dbname=test','dbuser','password',
                      {
                        RaiseError => 1,
                        AutoCommit => 0
                      }
                      ) || die "Database connection not made:
$DBI::errstr";

my $query = $dbh->prepare(
            "CREATE TABLE foo (foo_id INT4," .
            "foo_name TEXT)"
            );
$query->execute();
$dbh->disconnect();


Has anything changed to DBI? I haven't found anything on google
suggesting that it has.

-- 
Jeff Self
Dept. of Information Technology
City of Newport News
(757)926-3741




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Is there something wrong with Perl`s dbi and PostgreSQL?
  2003-09-29 17:51 Is there something wrong with Perl's dbi and PostgreSQL? Jeff Self <jself@nngov.com>
@ 2003-09-29 18:45 ` greg@turnstep.com
  0 siblings, 0 replies; 2+ messages in thread

From: greg@turnstep.com @ 2003-09-29 18:45 UTC (permalink / raw)
  To: pgsql-sql; +Cc: jself@nngov.com


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> I just tried running a perl script that I wrote about a year ago. It had
> worked for me in the past. Now it doesn't work.

You have AutoCommit set to off, and never commit the transaction. Therefore, 
the table creation is rolled back. Add a 

$dbh->commit()

after your execute line and it should work as expected.

Also note that your "die" on connect will not work because you have RaiseError 
set: Leave it off for the connect, then turn it on again immediately via:

$dbh->{RaiseError}=1;


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200309291445

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE/eH4AvJuQZxSWSsgRAgkVAJ46YX5iJ1+pbeJOQ6RJYId/6yhOWQCeKy7R
doP2RZN1y353MT+c4KdYywA=
=KUHS
-----END PGP SIGNATURE-----





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-09-29 18:45 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-29 17:51 Is there something wrong with Perl's dbi and PostgreSQL? Jeff Self <jself@nngov.com>
2003-09-29 18:45 ` Re: Is there something wrong with Perl`s dbi and PostgreSQL? greg@turnstep.com

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox