Leser: 21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use warnings; use strict; use DBI; my $datenbank = "mitarbeiterdaten"; my $host = "localhost"; my $dsn = "DBI:mysql:database=$datenbank;host=$host"; my $benutzer = "root"; my $passwort = "66666"; my $dbhandle = DBI::->connect( $dsn, $benutzer, $passwort) or die DBI::errstr; my $sql = qq(SELECT * FROM t_mitarbeiter); my $sth = $dbhandle->prepare($sql) or die $dbhandle->errstr; $sth->execute or die $sth->errstr; open(OUT, ">D:\\SQL_INHALT.txt"); print OUT $sth; close(OUT);
1 2 3 4 5
open my $out, ">", "D:\\SQL_INHALT.txt" or die $!; while ( my @row = $sth->fetchrow_array ) { print $out join ";", @row; } close $out;