есть ли способ заставить эту работу?
(напишите out_file в мой домашний каталог)
#!/usr/bin/perl
use warnings;
use strict;
use File::Spec::Functions;
use File::HomeDir;
use DBI;
my $database = 'my_db';
my $table = 'my_table';
my $user = 'user';
my $passwd = 'password';
my $dbh = DBI->connect( "DBI:mysql:$database;",
$user, $passwd, { RaiseError=>1, AutoCommit=>1 } );
$dbh->do( qq{ DROP TABLE IF EXISTS $table } );
$dbh->do( qq{ CREATE TABLE $table (
artikel INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
haendler CHAR(20) DEFAULT '' NOT NULL,
preis DOUBLE(16,2) DEFAULT '0.00' NOT NULL,
PRIMARY KEY( artikel, haendler ) ); } );
my $sth = $dbh->prepare( qq{ INSERT INTO $table
( artikel, haendler, preis )
VALUES( ?, ?, ? ) } );
$sth->execute( 1, 'Dotter', 1.35 );
$sth->execute( 2, 'Kahlo', 2.00 );
$sth->execute( 3, 'Schmidt', 4.30 );
$sth->execute( 3, 'Kahlo', 4.45 );
my $out_file = 'out_file.csv';
my $home_dir = File::HomeDir->my_documents;
$out_file = catfile $home_dir, $out_file;
$dbh->do( qq{ SELECT * INTO OUTFILE '$out_file'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"' LINES TERMINATED BY '\n'
FROM $table; } );
# DBD::mysql::db do failed: Can't create/write to file '/home/user/out_file.csv' (Errcode: 13) at ./mysql.pl line 44.