Yesterday, 7 Oct 2009, MySQL Workbench 5.2.4-alpha was released. What interests me in particular is that Workbench 5.2 brings support for writing plugins using Python. Before it was only possible using LUA.
Workbench comes with GRT (Generic RunTime) shell which allows you to access objects at runtime. It’s pretty neat, but how you enable it to use Python? Here is how:
- Open the Workbench Preferences dialog
- In the General section, set Interactive GRT Shell Language to Python.
- Restart Workbench
- Go to View > Advanced and choose CRT Shell.
It’s a bit of a chore writing in that shell as you can’t copy/paste (at least not in MacOS, workaround is to drag!). Here are a few commands you can do there (or check on the Workbench team blog). Make sure you have at least one Model open, and one table defined.
>>> import grt
>>> model = grt.root.wb.doc.physicalModels[0]
>>> for tab in model.catalog.schemata[0].tables:
... print "Table: `%s`" % (tab.name)
... Table: `t1`
Using the GRT shell it makes it possible to test first some lines of code. I do personally like it, although the shell feels still a bit buggy, but usable.