Tim Bunce wrote:
On Thu, May 11, 2006 at 08:59:25AM -0400, Mark Galbreath wrote:
Tim,
I have preactically memorized the docs I have read them so many times. If you have a better suggestion, I am wide open for it!
Something simple would do:
$sth = $dbh->prepare(...);
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
print join("|", @row), "\n";
}
(I'm assuming you know your data doesn't contain any | characters.)
And that the data doesn't contain any newlines. :-)
If you have embedded stuff, you might want:
my $csv_dbh = DBI->connect('dbi:CSV...);
my $mysql_dbh = DBI->connect('dbi:msqyl...);
my $mysql_sth = $mysql_dbh->prepare(... any MySQL query ...);
$csv_dbh->do(
"CREATE TABLE myCSV AS SELECT * FROM IMPORT(?)"
, {}
, $mysql_sth
);
That snippet will perform the MySQL query and create a properly escaped
CSV file of the results.
--
Jeff