programming-examples/perl/Database/Inserting into a Database.pl

15 lines
449 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
use DBI;
use strict;
my $username = "dbuser";
my $password = "dbpassword";
my $dsn = "dbi:mysql:goo:192.168.1.10";
my $dbh = DBI->connect($dsn,$username,$password) or die "Cannot connect to database: $DBI::errstr";
my $sth = $dbh->prepare("INSERT INTO urls VALUES('','http://www.demo.org/','suehring',unix_timestamp(),'query words')");
$sth->execute() or die "Cannot execute sth: $DBI::errstr";
$dbh->disconnect();