ratexdb Version 0.14
Unfortunately the Ruby people seem to have decided that DBI is
deprecated. Well, I couldn't be bothered to repair all this Ruby
stuff, install new packages etc. So, I cannot go on developing
ratexdb; instead I wrote an improved clone in C# called
nlatexdb.
So there I was, wanting to do database reports. MS reporting services
gave me tendovaginitis, so why not use Latex, I thought? Quickly I
found latexdb by Hans-Georg Eßer, and I liked the idea very much.
However, I needed it under Windows with an ODBC data source, and
latexdb is written in Python and Bash. My attempts to get it to run
failed, and I decided it would be more fun to rewrite it in Ruby and
include some improvements on the way.
- Should work easily on any platform (Windows, Unix...)
- You can connect to a wide variety of data sources, as supported by
the ruby-dbi package
(ODBC, PostgreSQL, MySQL, SQLite, and others).
- One source code file only, one language, should port easily to other
systems.
- Latexdb writes a series of output files for nested queries. Ratexdb
writes one output file only, nested queries are done by recursion.
- Added the \texdbif{##query}{latex stuff} command: Include "latex
stuff" only if the query returns at least one row. This is useful
for table headings, which can be omitted if there is no data anyway.
- In database results, Latex special characters (\, _, $, &, #, ~, {, }
and %) are replaced by appropriate Latex commands.
- Every variable can be included in the Latex source in one of three
flavours:
- ##varname in Latex source, replaces Latex special characters,
- $$varname in SQL queries, replaces ' by '',
- &&varname in SQL queries, accepts hexadecimal numeric input only.
The latter two are helpful to protect against SQL injection. The
$$varname variant is meant for string constants in SQL, the
&&varname variant for integer constants or GUIDs (used as primary key columns).
- The database results can be post-processed by regular expression
search and replace. So you can conveniently replace database key
columns by their long value, change the format of numeric or
timestamp fields, etc.
- Ratexdb allows command line arguments, which can be referenced in
the Latex source by variable names ##1, ##2, etc.
- Added the \texdbcommand{database command}, which sends SQL commands
directly to the database.
You need a Latex distribution and Ruby above version 1.8. I used
MiKTeX and Ruby 1.8.6.
Ratexdb is published under the GNU General Public License
and available here:
Added \texdbcommand.
Replaced ftools by FileUtils.
Removed an umlaut which seemed to give trouble.
Added "~" to LaTeX special characters, and changed "\" replacement
from "$\backslash$" to "\ensuremath{\backslash}".
After a \texdb... command, the first character after the last closing
} was lost. Fixed.
Changed ordering in postprocessing: First replace the special
characters, then the regular expressions. Like this, the regular
expressions can contain LaTeX commands.
Fixed bug in command line arguments parsing.
Changed line breaks from "\r\n" to "\n" to make it work on Unix and Mac.
Initial release.
Please read the README file for more information.
Just copy the Ruby script to a place where it is found. Under
Unix-like systems, you might have to give it execute permission using chmod.
counters.tex shows a possibility to fill a
tabular environment with data, using a LaTeX counter and the
ifthen
package.
Ratexdb is just a preprocessor. So it won't work with multi-part
documents (joined by the Latex "\input" command). You can
put the query definitions in each file, and run ratexdb on all of
them. But you won't be able to use SQL variables of one file in
another file.
Therefore, a kind user sent me an
awk script which
combines all Latex files in one resulting file:
latexmerge.awk
If you have a question, find a bug, like to propose an
improvement, or just wish to tell me you used this script successfully,
contact me!
Many thanks to Hans-Georg
Eßer for LatexDb.
Many thanks
to Oscar van Eijk
and his SQLTeX for inspiring the LaTeX characters change in
version 0.13. In fact, I'm considering adopting his "-r" command-line
parameter, which reads the LaTeX replacements from a file. Is there
anybody who would find this useful?
Many thanks to François Boone for helpful comments and bugfixes.
Many thanks to my employer, Integranova, for making software
development a breeze with the programming machine, and for allowing me
to publish this script under GPL. Speaking of which:
ratexdb is Copyright ©
2007-2010 Robin Höns,
Integranova GmbH.
It is released under the GNU
GPL,
a copy of which you find in the package after downloading.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Last Change: 5. August 2011 by Robin Höns