#!/usr/bin/perl -w #DatenbankAbfragen use strict; use warnings; use DBI; open(DAT, '<','../gate_common/MySQLAccount.txt') or die"Could not open SQL-Data-file!"; my $raw_data=; close(DAT); chomp $raw_data; my ($host,$user,$pass,$db) = split(/:/, $raw_data); print "host ".$host."\n"."user ".$user."\n"."pass ".$pass."\n"."db ".$db."\n"; my $dbh = DBI->connect("DBI:mysql:".$db.":".$host,$user,$pass) or die "Connect Error: $DBI::errstr()\n"; Query($dbh); $dbh->disconnect; sub Query{ my ($dbh) = @_; my @ergebnisse; my $query = "SELECT ID, NEID, TS, BState, Data_CISCO, MD5 FROM RC_CISCO"; my $sth = $dbh->prepare($query) or die "Querry Error prepare: $DBI::errstr\n"; $sth->execute or die "Querry Error execute: $DBI::errstr\n"; while(my @row = $sth->fetchrow_array()){ # push(@ergebnisse,\@row); print "@row\n"; } $sth->finish(); }