From 36cffe7aedd7e7efa2bcffc6b993240c89f5b51a Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Wed, 12 Jan 2011 16:41:21 +0100 Subject: [PATCH] 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 --- install/install.pl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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); -- 2.20.1