Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Allows inline SQL queries to be displayed as a table from within Trac wiki pages

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.rst

Wiki Table Plugin

Derived from work by optilude at http://trac-hacks.org/wiki/WikiTableMacro

This plugin allows you to query Databases from the wiki with a SQL query and display the results as a table.

Usage:

    {{{
    #!SQLTable
        SELECT count(id) as 'Number of Tickets'
        FROM ticket
}}}

This will create a table with one row and one column. You can obviously create more complex queries as you wish.

Querying other databases

To query a database other than Trac's built in one, add a DSN (MySQL, Postgres and Sqlite schemes are supported) to trac.ini under the "wikitable" section.

Example:

{{{
    [wikitable]
    foo = mysql://password:user@localhost/foo
    pgdb = postgres://password:user@localhost/bar
    trac-project1 = sqlite:///var/local/trac/project1/trac.db
}}}

Then add a dsn argument to the wiki tag. You can include multiple database tables on the same page:

{{{
    #!SQLTable dsn="foo"
        SELECT * FROM baa
}}}

Omitting the dsn argument will make the macro use Trac's database, so this:

{{{
    #!SQLTable
        SELECT count(id) as 'Number of Tickets'
        FROM ticket
}}}

Is the same as this:

{{{
    #!SQLTable dsn="trac-project1"
        SELECT count(id) as 'Number of Tickets'
        FROM ticket
}}}

Installation

Install as normal, using easy_install or 'python setup.py install'. Then add this to trac.ini:

[components]
wikitable.* = enabled
Something went wrong with that request. Please try again.