List:General Discussion« Previous MessageNext Message »
From:Bruce Ferrell Date:May 15 2009 12:04am
Subject:Re: Select Into OUTFILE problem
View as plain text  
Thanks all who replied.

After I posted I kept looking and found it... Also had folks point it
out to me.

Your suggestion is what I ended up doing.

Bruce



Gavin Towey wrote:
> Hi Bruce,
> 
>  
> 
> SELECT … INTO OUTFILE always creates the file local to the database
> server.  If you want to dump results where your perl script is running
> you’ll have to use another method such as receiving the results of the
> query normally and writing the file in the perl script.
> 
>  
> 
> Regards,
> 
> Gavin Towey
> 
>  
> 
>  
> 
> I have a bit of perl code that ends with an error:
> 
>  
> 
> $sql="SELECT convert_tz( a.stamp,'GMT','$tz' ) as ts, a.status,
> 
>              a.reason, a.tl
> 
>       INTO OUTFILE  '/application/result.csv'
> 
>       FIELDS TERMINATED BY ','
> 
>       ENCLOSED BY '\"'
> 
>       LINES TERMINATED BY '\n'
> 
>       FROM alerts a
> 
>       WHERE a.stamp BETWEEN ? AND ?
> 
>       ORDER BY a.stamp DESC";
> 
>  
> 
>  $sth = $dbh->prepare($sql);
> 
>  $rv = $sth->execute;
> 
>  
> 
> DBD::mysql::st execute failed: Can't create/write to file
> 
> '/application/result.csv' (Errcode: 2)
> 
>  
> 
> Te database is remote from the system where the perl is executing.
> 
>  
> 
> Te SQL works as expected when fed to mysql command line client
> 
> (i.e. mysql -h remote).  The outfile ends up in the application
> 
> directory of the macine running the mysql client.
> 
>  
> 
> What I'd found is, when the perl code runs the file tries to drop on the
> 
> database server and the application directory doesn't exist there giving
> 
> me the error.
> 
>  
> 
> Any suggestions to get the outfile to drop in the right place would be
> 
> appreciated.
> 
>  
> 
> Bruce
> 
>  
> 
>  
> 
> 
> ------------------------------------------------------------------------
> The information contained in this transmission may contain privileged
> and confidential information. It is intended only for the use of the
> person(s) named above. If you are not the intended recipient, you are
> hereby notified that any review, dissemination, distribution or
> duplication of this communication is strictly prohibited. If you are not
> the intended recipient, please contact the sender by reply email and
> destroy all copies of the original message.
Thread
Select Into OUTFILE problemBruce Ferrell13 May
RE: Select Into OUTFILE problemGavin Towey15 May
  • Re: Select Into OUTFILE problemBruce Ferrell15 May