programming-examples/perl/CGI/Creating a Table.pl

15 lines
642 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!\usr\bin\perl
use warnings;
use strict;
use DBI;
my ($dbh, $sth);
$dbh=DBI->connect('dbi:mysql:test','root','password') || die "Error opening database: $DBI::errstr\n";
$sth=$dbh->prepare("CREATE TABLE checkin (id INTEGER AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(32) NOT NULL,
lastname VARCHAR(32) NOT NULL,
destination VARCHAR(32) NOT NULL)");
$sth->execute(); # execute the statement
$sth->finish(); # finish the execution
print "All done\n";
$dbh->disconnect || die "Failed to disconnect\n";