[[PageOutline(2-5,Contents,pullout)]] = Execute an SQL Query == Description Execute an SQL Query against a configured database displaying a formatted table of results. 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 [http://trac-hacks.org/newticket?component=SqlQueryMacro&owner=JamesMills 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. == Example This macro can be used in one of two ways: {{{ {{{ #!SQL SELECT * FROM foo }}} }}} or: {{{ [[SQL(SELECT * FROM foo)]] }}} == Installation This macro requires the [https://bitbucket.org/prologic/pymills pymills] library and 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 `trac.ini`: {{{ #!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 uri = oracle://user:password@tns }}} or: {{{ #!ini uri = sqlite:///path/to/db }}} == 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:'''