wiki:SqlQueryMacro

Version 3 (modified by JamesMills, 7 years ago) (diff)

Updated with example confiugration for db uri

Execute an SQL Query

Description

Execute an SQL Query against a configured database displaying a formatter table of results.

Bugs/Feature Requests

Existing bugs and feature requests for SqlQueryMacro are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out SqlQueryMacro from here using Subversion, or browse the source with Trac.

Example

This macro can be used in one of two ways:

{{{
#!SQL
SELECT * FROM foo
}}}

or

[[SQL(SELECT * FROm foo)]]

Install

This macro requires the pymills library and makes use of it's db and table modules. Please install pymills first.

easy_install pymills

To install the macro:

easy_install TracSqlQueryMacro

To enable:

[components]
sqlquery.* = enabled

Configure

To configure this plugin, you must tell sqlquery what database to connect to:

In trac.ini (or via the Web Admin):

[sqlquery]
uri = mysql://user:password@hostname/database

You can also use oracle or sqlite:

uri = oracle://user:password@tns:/
or
uri = sqlite:///path/to/db

Recent Changes

[14239] by rjollos on 2014-11-04 13:21:22
Import of Connection fails, at least in the most recent version of pymills. Refs #12023.

Patch by paresh138@….

[14238] by rjollos on 2014-11-04 13:21:18
Added pymills to installation requirements.
[14237] by rjollos on 2014-11-04 13:21:15
Removed unused ITemplateProvider implementation.

Author/Contributors

Author: JamesMills
Contributors: