[[PageOutline(2-5,Contents,pullout)]]

= 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. For usage examples, see below.

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.

== Bugs/Feature Requests

Existing bugs and feature requests for !WikiTableMacro are [report:9?COMPONENT=WikiTableMacro here].

If you have any issues, create a [/newticket?component=WikiTableMacro new ticket].

[[TicketQuery(component=WikiTableMacro&group=type,format=progress)]]

== Download

Download the zipped source from [export:wikitablemacro here].

== Source

You can check out !WikiTableMacro from [/svn/wikitablemacro here] using Subversion, or [source:wikitablemacro browse the source] with Trac.

== Installation

 1. '''Install''' globally:
 {{{#!sh
sudo easy_install https://trac-hacks.org/svn/wikitablemacro/trunk
}}}
 1. '''Enable''' the plugin by updating TracIni file (`conf/trac.ini`):
 {{{#!ini
[components]
wikitable.* = enabled
}}}
 1. '''Restart''' web server on command line:
 {{{#!sh
sudo /etc/init.d/apache2 restart
}}}

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

== Recent Changes

[[ChangeLog(wikitablemacro, 3)]]

== Author/Contributors

'''Author:''' [wiki:optilude] [[BR]]
'''Maintainer:''' [[Maintainer]] [[BR]]
'''Contributors:''' jun66j5