MySQL Forums
Forum List  »  Perl

problem in creating a database table
Posted by: Zhen Dai
Date: April 27, 2007 12:44PM

Hi, there,
I am beginning in using Perl DBI. I have this problem in creating a database talbe using the LOAD DATA method. Can anybody help me and point out where I did wrong? Thanks!

Her is the Perl codes:
#*****************************************
use DBI;

my $dbh= DBI->connect('DBI:mysql:test','root', 'xxxxx')
or die "Could not connect to database:".DBI->errstr;
my $inFile = 'C:\documents\Projects\input.csv';

# read the csv data into MySQL database table.
my $query = "LOAD DATA LOCAL INFILE ? INTO TABLE mytable FIELDS TERMINATED BY ?";
$dbh->do($query, $inFile, ',');
.....


error message says:
DBI::db=HASH(0x1a67e44)->do(...): attribute parameter 'C:\documents\Projects\input.csv' is not a hash ref at process1.pl line
21.

Options: ReplyQuote


Subject
Written By
Posted
problem in creating a database table
April 27, 2007 12:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.