Using The SQL Query Tool

mojoPortal includes a simple SQL Query Tool that developers can use for ad hoc queries against the database. It is disabled by default. It is possible, with this tool, to delete site data and completely break a site. The SQL Query Tool lets the user see any data in the database that they know how to query for. If you are not a SQL expert, it is highly recommend that you leave this tool disabled to help prevent data loss. It is recommended that a backup of the database be made before each use of this tool. That said, it can be very useful for a variety of purposes including rapid development of small features.

To enable it, you need to add this to your user.config file:

<add key="EnableDeveloperMenuInAdminMenu" value="true" />
<add key="EnableQueryTool" value="true" />

With these settings enabled, the SQL Query Tool, only users in the Admins role of a root site have access, i.e. it is not available in child sites of a multi site installation. The data for all sites is stored in the database, allowing a user with access to this tool can see the data for any of the sites.

screen shot of SQL Query Tool

It has a list of tables in the database and can generate a simple statement for you with the click of a button. Queries can be saved and re-loaded later. Queries can also be retrieved by name and used for simple data access in small custom features as we will see in another article, how to populate a chart from a saved query. This approach, however, is not recommended for complex features. It is just very convenient for rapid development of small features.

Last Modified by Shawn Grout on Aug 19, 2022