Thread In die Datenbank Schreiben: In einer Tabelle der Datenbank (8 answers)
Opened by nour at 2006-12-04 12:24

renee
 2006-12-05 11:43
#34948 #34948
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Mach mal:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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=<DAT>;
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();
}
\n\n

<!--EDIT|renee|1165311869-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread In die Datenbank Schreiben: In einer Tabelle der Datenbank