[[PageOutline(2-5,Contents,pullout)]] = Execute an SQL Query from within Trac {{{#!box warning **Notice:** This plugin is deprecated in favor of SqlAlchemyQueryMacro. }}} == Description This plugin allows you to execute an SQL Query against a configured database displaying a formatted table of results from within Trac. See also: * SqlAlchemyQueryMacro: a plugin that supersedes !SqlQuery. * WikiTableMacro: a simpler implementation, which does not allow to define a datasource. == Bugs/Feature Requests Existing bugs and feature requests for SqlQueryMacro are [report:9?COMPONENT=SqlQueryMacro here]. If you have any issues, create a [/newticket?component=SqlQueryMacro new ticket]. == Download Download the zipped source from [download:sqlquerymacro here]. == Source You can check out SqlQueryMacro from [http://trac-hacks.org/svn/sqlquerymacro here] using Subversion, or [source:sqlquerymacro browse the source] with Trac. == Installation This macro requires the [https://bitbucket.org/prologic/pymills pymills] library and it makes use of its '''db''' and '''table''' modules. Please install pymills first. {{{#!sh wget https://bitbucket.org/prologic/pymills/get/0d1424e1b0ab.zip unzip 0d1424e1b0ab.zip easy_install $PWD/prologic-pymills-0d1424e1b0ab }}} To install the macro: {{{#!sh easy_install TracSqlQueryMacro }}} To enable in your `trac.ini` file: {{{#!ini [components] sqlquery.* = enabled }}} == Configuration To configure this plugin, you must tell SQLQuery what database to connect to. In `trac.ini` or via the WebAdmin menu: {{{#!ini [sqlquery] uri = mysql://user:password@hostname/database }}} You can also use Oracle or SQLite: {{{#!ini [sqlquery] uri = oracle://user:password@tns }}} or: {{{#!ini [sqlquery] uri = sqlite:///path/to/db }}} == Example This macro can be used in one of two ways: {{{ {{{ #!SQL SELECT * FROM foo }}} }}} or: {{{ [[SQL(SELECT * FROM foo)]] }}} == Feedback Please give your feedback (''anything that shouldn't be a ticket'') [wiki:SqlQueryMacro/Feedback here] == Recent Changes [[ChangeLog(sqlquerymacro, 3)]] == Author/Contributors '''Author:''' JamesMills [[BR]] '''Maintainer:''' [[Maintainer]] [[BR]] '''Contributors:'''