From: Thomas Hochstein Date: Wed, 12 Jan 2011 15:41:21 +0000 (+0100) Subject: Add database creation to installer. X-Git-Tag: 0.01~1^2~6^2~2 X-Git-Url: https://code.th-h.de/?p=usenet%2Fnewsstats.git;a=commitdiff_plain;h=36cffe7aedd7e7efa2bcffc6b993240c89f5b51a;hp=da6fc073eed91506a94ae96471b19b6f22b72cb0 Add database creation to installer. It's not enough to create tables, one should create the database first if it is still missing ... Signed-off-by: Thomas Hochstein --- diff --git a/install/install.pl b/install/install.pl index 8ab7798..374d74b 100755 --- a/install/install.pl +++ b/install/install.pl @@ -47,6 +47,10 @@ my %Conf = %{ReadConfig($HomePath.'/newsstats.conf')}; ##### Database table definitions ##### -------------------------------------------------------------------------- +my $DBCreate = < < <connect(sprintf('DBI:%s:host=%s',$Conf{'DBDriver'}, + $Conf{'DBHost'}), $Conf{'DBUser'}, + $Conf{'DBPw'}, { PrintError => 0 }); + my $DBQuery = $DBHandle->prepare($DBCreate); + $DBQuery->execute() or &Bleat(2, sprintf("Can't create database %s: %s%\n", + $Conf{'DBDatabase'}, $DBI::errstr)); + + printf("Database table %s created succesfully.\n",$Conf{'DBDatabase'}); + $DBHandle->disconnect; +}; + ### DB init, read list of tables print "Reading database information.\n"; my $DBHandle = InitDB(\%Conf,1); @@ -158,7 +179,6 @@ my %TablesInDB = if (!$OptUpdate) { ##### installation mode - print "----------\nStarting database table generation.\n"; # check for tables and create them, if they don't exist yet foreach my $Table (keys %DBCreate) { &CreateTable($Table);