> Is there a way to do report writing from Mysql databases? I want to
>transfer all the records from Mysql to a file. i used the Into OUTFILE but it
>doesnt display properly.I want to diplay it properly like records or reports.
I wrote a basic Perl script to prettify the output of a MySQL query that
gets outputted in tab delimited format. So you would run MySQL with the
-B and -r flags and pipe the output through this script:
--- cut here ---
#!/usr/bin/perl
# input: a tab delimited file, as might come from a MySQL query
# output: the same data, arranged so that each column accommodates
# the maximum length of the data in that column
$i = 0;
while (<>) {
chomp;
# s/\\\\/\\/g;
@data = split("\t");
@sizes = map(length,@data);
$i++;
@sizevec[$i] = join("\t",@sizes);
@datavec[$i] = $_;
for ($j=0;$j<[EMAIL PROTECTED];$j++) {
$maxsize[$j] = $sizes[$j] if $maxsize[$j] < $sizes[$j];
}
}
for ($i=0; $i<@datavec;$i++) {
@sizes = split("\t",@sizevec[$i]);
@data = split("\t",@datavec[$i]);
for ($j=0;$j<[EMAIL PROTECTED];$j++) {
$_ = $data[$j];
$l = length;
$m = $maxsize[$j];
$padding = " " x ($m - $l);
if (/^[0-9. -]*$/) { print $padding . $_ ; }
else { print $_ . $padding ; }
print " ";
}
print "\n";
}
--- ereh tuc ---
--
Steve Bacher
Draper Laboratory
Cambridge, MA, US
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]