[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Connect to PostgreSQL database
* Fred Pope wrote on Thu, Mar 14, 2002 at 16:47 -0700:
> * Northern Sun wrote:
> > Using psql gets me - connect failed -- unknown error. Driver psql installed?
> > Using Pg gets me - DBI->connect(database:localhost:5432) failed. ERROR -
> > missing = after 'database:localhost:5432' in conninfo ... Table/DBI.pm line
> > 445
Maybe it's right and the PG driver is missing? I suggest to check
it before continuing.
You may try some perl script like:
#!/usr/bin/perl -w
#tihs is c&p and may not work :)
my @dbi_c = ();
@dbi_c = ($ARGV[0], "", ""); #dns, user, pass
use strict;
use DBI;
my $drv_c = "";
if ($dbi_c[0] =~ m/^dbi:(\w+):/i) {
$drv_c = $1;
} else {
print "Warning, couldn't parse ", $dbi_c[0], ", no dbi:???: found\n";
}
print "-------------[ Drivers ]-------------\n";
my @drv = DBI->available_drivers;
my $drv;
foreach $drv (@drv) {
if ($drv eq $drv_c) {
print "* Driver: $drv (will be used)\n";
} else {
print "- Driver: $drv\n";
}
}
print "\n";
if ($drv_c =~ /\S/) {
print "-------------[ $drv_c DS ]-------------\n";
my @ds = DBI->data_sources($drv_c);
foreach my $ds (@ds) {
print "$ds\n";
}
print "\n";
} else {
print "No Driver: SKIPPING data_sources!\n";
}
#adapt the settings according to /etc/odbc.ini:
my $conn = DBI->connect(@dbi_c,
{ RaiseError => 1, AutoCommit => 0 }
);
if (!$conn) {
die "couldn't connect\n";
} else {
print "*** SUCCESS: DATABASE CONNECTED.\n";
}
#now work a little with conn here.
> > I set up a postgreSQL database with a products table, and loaded it with
> > data.
> If you look at the structure of the PGSQL database, there is a lot more than
> just the products table. Try building a catalog and having the IC build the
> DB for you. Then work backwards.
I think the installer copies some scripts always, maybe check the
config directory, maybe you'll find the shema and can feed it
into psql.
> > Do I also need column names in the /products/products.asc file if I
> > want to access the data from the postgreSQL database products table?
No, I wouldn't use the .asc files. IC supports to rebuild the
database tables from text sources, but I don't like this at all.
Better use NoImport and friends in catalog config.
oki,
Steffen
--
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.