#!usr/bin/perl use warnings; use strict; use DBI; my $datenbankname = "datenbank.db"; #-----------------DATENBANK-VERBINDUNG------------------# my $database = DBI::->connect("dbi:SQLite:dbname=$datenbankname","","") or die "Fehler bei Datenbankverbindung!"; #----------------DATENBANK-VERBINDUNG-ENDE--------------# #---------------UEBERPRUEFUNG-EXIST-------------# my $exist = $database->selectall_arrayref( "SELECT * from schueler" ); if ( defined $exist ) # { #----------------LOESCHT-TABELLE--------------# my $sql = 'DROP TABLE schueler'; $database->do($sql) or die $database->errstr; #----------------LOESCHT-TABELLE-ENDE-------------# } else { print "Es konnte auf keine existierende Datei zugegriffen werden"; print "\n"; print "Bitte laden Sie er die Schueler in die Datenbank"; print "\n"; exit; } #------------UEBERPRUEFUNG-EXIST-ENDE------------# #---------------DATENBANK-VERBINDUNG-DISCONNECT-------------# $database->disconnect or $database->errstr; #------------DATENBANK-VERBINDUNG-DISCONNECT-ENDE------------#