wiki:WikiTableMacro

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 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.

Usage

Use the SQLTable macro as follows:

{{{#!SQLTable
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:

{{{#!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

  1. Install globally:
    sudo easy_install https://trac-hacks.org/svn/wikitablemacro/trunk
    
  2. Enable the plugin by updating TracIni file (conf/trac.ini):
    [components]
    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.

defect

6 / 6

enhancement

4 / 6

task

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

[14531] by rjollos on 2015-04-13 21:24:22
0.3dev: Fix issue fetching from cursor on MySQL.

Patch by theYT <dev@…>. Fixes #12269.

[14524] by rjollos on 2015-04-09 02:08:20
0.3dev: Use Trac 1.0 DB API.

  • Macro now requires Trac 1.0 and later.
  • Genshi is used to construct the table.
  • Queries can use non-ASCII table names. Fixes #11708.
  • Read-only database connection is used.

Please report any issues with the latest changes.

[14523] by rjollos on 2015-04-09 00:34:21
0.2: Tagging version 0.2.

Author/Contributors

Author: optilude
Maintainer: rjollos
Contributors: jun66j5

Last modified 4 weeks ago Last modified on Mar 28, 2015, 2:41:55 PM