DbUtil Plugin

  • Authors : null
3 votes
Dependency :
compile ":db-util:0.4"

Documentation

Summary

Description

DbUtil Plugin

Description:

This plugin exists to allow a developer to quickly access the database for a running Grails application. Some embedded dbs, like derby only allow access to the db from within the JVM that has launched the db. Others such as the in-memory HSQL may not provide an decent tool to quickly see what the database looks like for a newly created Grails app. To get around these limitations I wrote this small plugin (1 controller & 3 gsps) that can be used to admin the db within a Grails app as it is running. Simply install the plugin into your existing app, run your app and go to http://server:port/appName/dbUtil to access the database screens. Check out the Screenshots tab to see exactly what the plugin provides.

Install:

grails install-plugin db-util

Usage:

There are three actions with the following urls described below…
  • /$appname$/dbUtil/info - Shows info about the db (tables/columns/column type, etc)
  • /$appname$/dbUtil/data - Outputs all the actual data alphabetically by table
  • /$appname$/dbUtil/sql - Allows free-form select/update/delete commands
Note: I've included commons-dbutils-1.1 from apache in the lib directory.

IMPORTANT: You will definitely want to protect this controller's url from unauthorized access since the sql action can be used to do just about anything.

Files:

  • DbutilController.groovy
  • data.gsp
  • info.gsp
  • sql.gsp

Next Steps:

  • With the "configuration by environment" feature of Grails 1.1 I hope to add the ability to control whether this plugin is installed into a production app. Because it is a security hole, by default I plan to disable the plugin in production.

Version Notes:

  • 0.4 - Upgraded to Grail 1.1 and fixed related bugs
  • 0.3 - 1.0.x