On Mon, 28 Jan 2002, David S. Jackson wrote:
> I'm just starting my first MySQL db, and I'm going to want to
> print out reports from it and produce a camera-ready document.
> Has anyone done this before, using, say, Star Office or AbiWord
> or something?
David,
I go this way for high quality output:
echo "$QUERY" | mysql db | filter.sh > tempfile.tex
tex tempfile.tex --> tempfile.dvi
dvips tempfile.dvi --> tempfile.ps
filter.sh may be quite complex. It is a shell script
(or you can use perl) launching sed or awk to produce
the TeX source. The appendix is an example of a filter
to produce verbatim output from plain ASCII text
with fixed spacing.
Thomas Spahni
(pass the spam filter: MySQL table database query)
#!/bin/sh
# print ASCII texts "AS IS"
# this acts like a filter: taking input from stdin
# and sending output to the printer
# these are user-definable
TMPDIR="/tmp"
TMPFILE="printfile"
PRINTER="lpr -Php"
# --- no user configuration beyond this line ---
TMPDEST="${TMPDIR}/${TMPFILE}"
# just to avoid any conflicts:
# tmpfile is our lockfile at the same time
if test -e "${TMPDEST}.tex" ; then
echo "$TMPDEST exists; aborting" >&2
exit 1
fi
# create the necessary header first
cat > ${TMPDEST}.tex <<-'XXX'
\message{A4 paper size}%
\hsize 159.2mm %210mm - 1in * 2 for margins
\vsize 246.2mm %297mm - 1in * 2 for margins
% Define special characters for direct use
\catcode`�=\active \def�{\c{C}} \catcode`�=\active \def�{\"u}
\catcode`�=\active \def�{\'e} \catcode`�=\active \def�{\^a}
\catcode`�=\active \def�{\"a} \catcode`�=\active \def�{\`a}
\catcode`�=\active \def�{{\aa}} \catcode`�=\active \def�{\c{c}}
\catcode`�=\active \def�{\^e} \catcode`�=\active \def�{\"e}
\catcode`�=\active \def�{\`e} \catcode`�=\active \def�{{\"\i}}
\catcode`�=\active \def�{{\^\i}} \catcode`�=\active \def�{{\`\i}}
\catcode`�=\active \def�{\"A} \catcode`�=\active \def�{{\AA}}
\catcode`�=\active \def�{\'E} \catcode`�=\active \def�{{\ae}}
\catcode`�=\active \def�{{\AE}} \catcode`�=\active \def�{\^o}
\catcode`�=\active \def�{\"o} \catcode`�=\active \def�{\`o}
\catcode`�=\active \def�{\^u} \catcode`�=\active \def�{\`u}
\catcode`�=\active \def�{\"O} \catcode`�=\active \def�{\"U}
\catcode`�=\active \def�{\'a} \catcode`�=\active \def�{{\'\i}}
\catcode`�=\active \def�{\'o} \catcode`�=\active \def�{\'u}
\catcode`�=\active \def�{\~n} \catcode`�=\active \def�{\~N}
\catcode`�=\active \def�{{\ss}} \def\quest{?}
%
% strange fontsize to ensure that 80 characters make up one line
\font\vtt=cmtt10 at 10.77pt
\footline={\vtt\hfil - \the\pageno\ -\hfil}
%
\def\uncatcodespecials{\def\do##1{\catcode`##1=12 } \dospecials}
\def\setupverbatim{%
\par \vtt \spaceskip=0pt % Make sure we get fixed vtt spacing
\obeylines\uncatcodespecials\obeyspaces\verbatimdefs}
% This macro turns on verbatim mode until ?endverbatim is seen.
\def\verbatim{\begingroup \setupverbatim
\parskip=0pt plus .05\baselineskip \parindent=0pt
\catcode`\ =13 \catcode`\^^M=13 \catcode`\?=0
\verbatimgobble}
{\catcode`\^^M=13{\catcode`\ =13\gdef\verbatimdefs{\def^^M{\ \par}\let =\ }}
\gdef\verbatimgobble#1^^M{}}
% This defines ?endverbatim to end the group which begins with \verbatim
\let\endverbatim=\endgroup
\let\|=\relax
\verbatim
XXX
#echo -e "\n" >> ${TMPDEST}.tex
# now add what we get from stdin
cat - | sed -e "s/?/?quest?|/g" >> ${TMPDEST}.tex
# add the tail
cat >> ${TMPDEST}.tex <<-'XXX'
?endverbatim
\vfill\eject
\end
XXX
sync
(cd $TMPDIR && tex ${TMPFILE}.tex)
if test -r "${TMPDIR}/${TMPFILE}.dvi" ; then
(cd $TMPDIR && dvips $DVIARGS ${TMPFILE}.dvi)
$PRINTER "${TMPDIR}/${TMPFILE}.ps"
fi
# clean up
(cd $TMPDIR && rm -f \
${TMPFILE}.tex ${TMPFILE}.log ${TMPFILE}.dvi ${TMPFILE}.ps)
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php