Contents
SQL Table in Wiki Page
Description
This is a simple macro that enables you to place tables resulting from SQL queries into a wiki page.
It is similar to, but simpler than, SqlQueryMacro. The main differences are that it has fewer dependencies and always queries the Trac database, rather than letting you set up a separate data connection.
Usage
Use the SQLTable macro:
{{{ #!SQLTable SELECT count(id) as "Number of Tickets" FROM ticket }}}
The result will be a table.
You can also use wiki markup in the table:
{{{ #!SQLTable SELECT '[milestone:' || name || ' ' || name || ']' as name, due, completed, description FROM milestone }}}
Use the SQLScalar macro:
{{{ #!SQLScalar SELECT count(id) as "Number of Tickets" FROM ticket }}}
The result will be a single number.
Installation
- Install globally with:
sudo easy_install https://trac-hacks.org/svn/wikitablemacro/0.11/
- Enable the plugin by updating TracIni file (..../trac.ini) as follows:
[components] wikitable.* = enabled
- Restart web server on command line:
$ sudo /etc/init.d/apache2 restart
Bugs/Feature Requests
Existing bugs and feature requests for WikiTableMacro are here.
If you have any issues, create a new ticket.
Source & Download
You can check out WikiTableMacro from here using Subversion, or browse the source with Trac.
Download the zipped source from here.
Recent Changes
[12646] by rjollos on 02/21/13 22:25:58
Fixes #10814: Patch by Jun Omae (jun66j5) to fix a regression introduced in [12459]. Ensure that a string is passed to format_to_html.
Lightly tested against Trac 1.1.2dev-r11682.
[12459] by rjollos on 12/21/12 17:08:08
Refs #4452, #10724: Parse table data as wiki markup and format to HTML.
[12456] by rjollos on 12/21/12 13:12:14
Display a message on the page when the SQL is invalid, and prevent the page from being locked to further edits.
[12455] by rjollos on 12/21/12 12:22:22
Fixes #10718 (0.2dev): Use Trac 0.11+ API, replacing implementation of render_macro with expand_macro.

