Allows inline SQL queries to be displayed as a table from within Trac wiki pages
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
0.12
LICENSE
README.rst

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