SQL Table in Wiki Page


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 or SqlAlchemyQueryMacro. The main differences are that it has fewer dependencies and always queries the Trac database, rather than requiring you to set up a separate database connection.


Use the SQLTable macro as follows:

SELECT count(id) as "Number of Tickets"
FROM ticket

The result will be a table displayed in a html page.

You can also use wiki markup in the table:

SELECT '[milestone:' || name || ' ' || name || ']' as name, due, completed, description
FROM milestone 

Use the SQLScalar macro:

SELECT count(id) as "Number of Tickets"
FROM ticket

The result will be a single number.


  1. Install globally:
    sudo easy_install
  2. Enable the plugin by updating TracIni file (conf/trac.ini):
    wikitable.* = enabled
  3. 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.


4 / 5


4 / 6


3 / 3

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

[13683] by rjollos on 2014-02-19 12:53:57
Trimmed whitespace using
[12646] by rjollos on 2013-02-21 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 2012-12-21 17:08:08
Refs #4452, #10724: Parse table data as wiki markup and format to HTML.


Author: optilude
Maintainer: rjollos
Contributors: jun66j5

Last modified 18 hours ago Last modified on Mar 28, 2015, 2:41:55 PM