Re: Need help with Perl and MySQL database data load
From: Oscar (oscar_at_nowhere.com)
Date: 01/18/05
- Next message: Jürgen Exner: "Re: Print question"
- Previous message: Jürgen Exner: "Re: [perl-python] 20050117, filter, map"
- In reply to: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Next in thread: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Reply: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 Jan 2005 00:50:56 GMT
Tore Aursand wrote:
> Oscar wrote:
>
>> I'm not sure what top-post refers to. Hope I'm not doing it now.
>
>
> You are. Top-posting means that you are posting your answer in front of
> the part you are answering. That's a bad habit; it's like answering
> someone before you've even heard the question.
>
>> #!/perl/bin/perl -w
>> #insert data into mysql
>> use strict;
>> use DBI;
>
>
> If you're running a newer version of Perl, you should change this to:
>
> #!/usr/bin/perl
> #
> use strict;
> use warnings;
>
>> package MySQL;
>
>
> Don't do that. You are telling Perl that you're creating a package named
> 'MySQL' with this line. You aren't doing that, are you?
>
>> my $dsn = 'DBI:mysql:database=sd_tst;host=localhost;port=3306';
>> my $user = 'root';
>> my $pass = 'xxxxxxx';
>> my %args = ( RaiseError => 1,
>> AutoCommit => 1 );
>>
>> my $dbh = DBI->connect( $dns, $user, $pass, \%args )
>> or die "Can't connect; $DBI:errstr";
>>
>> $dbh->do("LOAD DATA LOCAL INFILE '/sd_data/audit_20041208.txt' INTO TABLE
>> sd_tst FIELDS TERMINATED BY '\|' LINES TERMINATED BY '\r\n';");
>>
>> $dbh->disconnect ();
>
>
> What error message(s) do you get? I haven't imported files this way in a
> long time, so I'm not sure if the syntax is right, but I'm sure you've
> read the documentation?
>
>
Hello,
When I remove the line
use DBI; I get the error message "Can't locate object method "connect"
via packge "DBI" (perhaps you forgot to load "DBI"?) at sqltst2.pl line 12."
When I put that line, use DBI;, back in I then get an authentication
procotol error message:
"DBI connect
('database=sds_tst;host=localhost;port=3306,'root',....)failed: Client
does not support authentication protocol requested by server;consider
upgrading MYSQL client at sqltst2.pl line 13."
I have the latest MySQL client installed.
I have reviewed the DBI documentation however just about all of the
examples contained refer to Perl on a UNIX box connecting to an Oracle
database. I use the path /perl/bin/perl as this is where my executables
are located. I don't have the usual USR directory since I am not using
UNIX/Linux.
My PC is WindowsXP connecting to MySQL (4.1). Here is the latest
version of the Perl script:
Thanks,
Oscar
#!/perl/bin/perl -w
#insert data into mysql
use strict;
use warnings;
use DBI;
my $dsn = 'DBI:mysql:database=sd_tst;host=localhost;port=3306';
my $user = 'root';
my $pass = 'xxxxxxx';
my %args = ( RaiseError => 1,
AutoCommit => 1 );
my $dbh = DBI->connect( $dsn, $user, $pass, \%args )
or die "Can't connect:". dbi->errstr;
$dbh->do("LOAD DATA LOCAL INFILE '/sd_data/audit_20041208.txt' INTO TABLE
sd_tst FIELDS TERMINATED BY '\|' LINES TERMINATED BY '\r\n';");
$dbh->disconnect ();
#EOF
- Next message: Jürgen Exner: "Re: Print question"
- Previous message: Jürgen Exner: "Re: [perl-python] 20050117, filter, map"
- In reply to: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Next in thread: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Reply: Tore Aursand: "Re: Need help with Perl and MySQL database data load"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|