digger has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for your wisdom,my $dir='../admin/'; my $table='EVENTS'; my $dbh= DBI->connect("DBI:CSV:f_dir=$dir")or die "Cannot connect: " . + $DBI::errstr; #if the table does not exist, make it #since we are using DBD:CSV, I am not sure that the field type/size de +clarations #are necessary, or even applied. Including them will make the code mor +e portable if #we move to mysql in the future. if (! -e "$dir$table") { print "making table $dir$table"; my $sth= $dbh->prepare ("CREATE TABLE $table (ukey CHAR(20), city CHAR(45), date CHAR(10), time CHAR(8), title CHAR(64), location CHAR(250), contact CHAR(64), email CHAR(60), phone CHAR(14) type CHAR(1))") or die "Cannot prepare: " . $dbh->errstr( +); $sth->execute() or die "Cannot execute: " . $sth->errstr(); } my $sth=$dbh->prepare(qq{INSERT INTO $table VALUES (?,?,?,?,?,?,?,?,?, +?)}) or die "Cannot prepare: " . $dbh->errstr(); $sth->execute(@fieldvals) or die "Cannot execute: " . $sth->errstr();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD:CSV and creating a database
by Cabrion (Friar) on Jan 31, 2003 at 02:34 UTC | |
|
Re: DBD:CSV and creating a database
by crouchingpenguin (Priest) on Jan 31, 2003 at 01:39 UTC | |
by Anonymous Monk on Jan 31, 2003 at 02:02 UTC | |
|
Re: DBD:CSV and creating a database
by Anonymous Monk on Jan 31, 2003 at 04:51 UTC |