cvs-to-sql.pl 597 Bytes
Newer Older
Dries's avatar
 
Dries committed
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl -w

use DBI;

my $db_name = 'drupal';
my $db_user = 'drupal';
my $db_pass = 'drupal';

my $files = $ARGV[0];
my @message = <STDIN>;
my $message = join '' , @message;
Dries's avatar
 
Dries committed
12
my $user = $ARGV[1];
Dries's avatar
 
Dries committed
13 14 15 16 17
my $timestamp = time();

my $db = DBI->connect("DBI:mysql:$db_name", "$db_user", "$db_pass") or die "Couldn't connect to database: " . DBI->errstr;
$db->do("INSERT INTO cvs (user, files, message, timestamp) VALUES (". $db->quote($user) .", ". $db->quote($files) .", ". $db->quote($message) .", ". $db->quote($timestamp) .")") or die "Couldn't execute query: " . $db->errstr;
$db->disconnect();