Skip site navigation (1) Skip section navigation (2)

Create tables using Perl DBI

From: "David Coley" <davidcoley(at)home(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Create tables using Perl DBI
Date: 2000-11-20 20:50:43
Message-ID: HEEKIDKMKOPLHIMFOPMLMEICCDAA.davidcoley@home.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
I've been trying to learn how to use PostgreSQL and Perl together on a test
machine at work.  My problem is that I can not seem to get it working.  The
documentation on the subject don't seem to be that in-depth and tutorials
seem lacking :)

Below is my third or forth try at getting my database to connect and create
a table.  I've included the error code for the code snippet.  Any help would
be GREATLY appreciated.


=== Begin Code ===

#!/usr/bin/perl

# Use the Database Binding Interface
use DBI;

# We want to use the  database which is kwsclient
$dbh = DBI->connect("dbi:Pg:dbname=kwsclient","db","PASSWORD")
	or die "Connecting: $DBI::errstr";

#abcdefghijklmnopqrstuvwxyz
$sth = $dbh->prepare("create table customer (ID serial PRIMARY KEY, name
text NOT NULL, 					email text NOT NULL, phone text NOT NULL, fax text
DEFAULT, address 				text NOT NULL, address2 text DEFAULT, zip text NOT
NULL, city text 				NOT NULL, state text NOT NULL, country text NOT NULL")
			or die "Could not Create Table: $DBI::errstr";
$sth->execute;
#disconnect from the database.
$dbh->disconnect();
# END

=== End Code ===

=== Error Message ===
DBD::Pg::st execute failed: ERROR:  parser: parse error at or near ","


Thanks for the help.

David Coley
davidcoley(at)home(dot)com
http://www.davidcoley.com


Responses

pgsql-interfaces by date

Next:From: Cedar CoxDate: 2000-11-20 21:23:02
Subject: Re: Password to install the odbc driver
Previous:From: Joseph ShraibmanDate: 2000-11-20 19:54:50
Subject: Re: [INTERFACES] Re: no meaningful way to determine fe or be version?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group