Changes between Version 16 and Version 17 of SqlAlchemyQueryMacro
- Timestamp:
- Aug 20, 2015, 9:19:58 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SqlAlchemyQueryMacro
v16 v17 1 1 [[PageOutline(2-5,Contents,pullout)]] 2 2 3 = Execute an SQL query 3 = Execute an SQL query from within Trac 4 4 5 5 == Description 6 6 7 Execute an SQL Query against a configured database displaying a formatted table of results. The macro uses [http://www.sqlalchemy.org/ SQLAlchemy], the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.7 This plugin allows you to execute an SQL Query against a configured database displaying a formatted table of results from within Trac. The macro uses [http://www.sqlalchemy.org/ SQLAlchemy], the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. 8 8 9 9 A previous version of this module is known as SqlQueryMacro. … … 17 17 18 18 If you have any issues, create a 19 [ http://trac-hacks.org/newticket?component=SqlAlchemyQueryMacro new ticket].19 [/newticket?component=SqlAlchemyQueryMacro new ticket]. 20 20 21 21 [[TicketQuery(component=SqlAlchemyQueryMacro,group=type,format=progress)]] … … 31 31 SqlAlchemyQueryMacro comes with sortable tables using the [http://www.kryogenix.org/code/browser/sorttable/ sorttable] library, written in Javascript. 32 32 33 == Example34 35 This macro can be used in one of two ways:36 {{{37 {{{38 #!SQL39 SELECT * FROM foo40 }}}41 }}}42 43 or:44 45 {{{46 [[SQL(SELECT * FROM foo)]]47 }}}48 49 33 == Installation 50 34 … … 54 38 After getting the source you will have to edit {{{ install_sqlalchemyquery.bash }}} to your needs, you can change: 55 39 {{{#!ini 56 TRAC_PATH_REPLACE ="/path/to/your-trac-environment" # absolute path to your trac environment57 TRAC_REPLACE ="your_trac_environment" # name of your trac environment ( relative path without slashes )58 MAX_ROW_COUNT_REPLACE ="1000" # maximum numbers of rows for the query result to display59 TABLE_BORDER_REPLACE ="border=\"1\"" # set the border with of the table40 TRAC_PATH_REPLACE = "/path/to/your-trac-environment" # absolute path to your trac environment 41 TRAC_REPLACE = "your_trac_environment" # name of your trac environment ( relative path without slashes ) 42 MAX_ROW_COUNT_REPLACE = "1000" # maximum numbers of rows for the query result to display 43 TABLE_BORDER_REPLACE = "border=\"1\"" # set the border with of the table 60 44 }}} 61 45 62 46 To install the macro: 63 47 {{{#!sh 64 65 48 tar -zxvf SqlAlchemyQuery.tar.gz 49 cd SqlAlchemyQuery 66 50 --- edit install_sqlalchemyquery.bash --- 67 51 ./install_sqlalchemyquery.bash … … 76 60 --- edit install_sqlalchemyquery.bash --- 77 61 ./install_sqlalchemyquery.bash 78 79 62 }}} 80 63 81 To enable this plugin add the following to `trac.ini`:64 To enable this plugin add the following to your `trac.ini` file: 82 65 {{{#!ini 83 66 [components] … … 99 82 100 83 {{{#!ini 84 [sqlalchemyquery] 101 85 uri = oracle://user:password@tns 102 86 }}} … … 105 89 106 90 {{{#!ini 91 [sqlalchemyquery] 107 92 uri = sqlite:///path/to/db 108 93 }}} 109 94 110 95 Restart tracd after making these changes. 96 97 == Example 98 99 This macro can be used in one of two ways: 100 {{{ 101 {{{ 102 #!SQL 103 SELECT * FROM foo 104 }}} 105 }}} 106 107 or: 108 109 {{{ 110 [[SQL(SELECT * FROM foo)]] 111 }}} 111 112 112 113 == Recent Changes