Thread Platzierung Pfadangabe bei DBD unklar (18 answers)
Opened by geloescht at 2012-09-15 00:25

geloescht
 2012-09-15 00:58
#161808 #161808
User since
2012-06-19
141 Artikel
BenutzerIn
[default_avatar]
Hallo nochmal,

Habe diesen Lerncode versucht:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
use warnings;
use DBI;

# Connect to the database, (the directory containing our csv file(s))

my $dbh = DBI->connect("DBI:CSV:f_dir=../prospects.csv;csv_eol=\n;");

# Associate our csv file with the table name 'prospects'

$dbh->{'csv_tables'}->{'prospects'} = { 'file' => 'prospects.csv'};

# Output the name and contact field from each row

my $sth = $dbh->prepare("SELECT * FROM prospects WHERE name LIKE 'G%'");
$sth->execute();
while (my $row = $sth->fetchrow_hashref) {
print("name = ", $row->{'Name'}, "  contact = ", $row->{'Contact'}. "\n");
}
$sth->finish();


Das ergab immer diesen Fehler:

Quote
Use of uninitialized value in concatenation (.) or string at ./DB-Test.pl line 19.
Use of uninitialized value in print at ./DB-Test.pl line 19.
name = contact =
Use of uninitialized value in concatenation (.) or string at ./DB-Test.pl line 19.
Use of uninitialized value in print at ./DB-Test.pl line 19.
name = contact =


Die CSV-Datei sieht so aus:

Quote
"Name","Address","Floors","Donated last year","Contact"
"Charlotte French Cakes","1179 Glenhuntly Rd",1,"Y","John"
"Glenhuntly Pharmacy","1181 Glenhuntly Rd",1,"Y","Paul"
"Dick Wicks Magnetic Pain Relief","1183-1185 Glenhuntly Rd",1,"Y","George"
"Gilmour's Shoes","1187 Glenhuntly Rd",1,"Y","Ringo"


Scheint als wär das Verbinden mit DBI oder DBD:CSV gar nicht so einfach.

Gruss und Gute Nacht

HP-User
Past brought us "SYS 64738". Present brought us "ctrl+alt+del". But what will future bring?

View full thread Platzierung Pfadangabe bei DBD unklar