ratexdb Version 0.1
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 me 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.
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:
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.
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 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 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: 29. November 2007 by Robin Höns