Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский
MySQL Workbench: Enabling Python in the GRT shell
+0 Vote Up -0 Vote Down

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:

  1. Open the Workbench Preferences dialog
  2. In the General section, set Interactive GRT Shell Language to Python.
  3. Restart Workbench
  4. 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.

Votes:

You must be logged in with a MySQL.com account to vote on Planet MySQL entries. More information on PlanetMySQL voting.

Planet MySQL © 1995-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Sun Microsystems, Inc. and does not
necessarily represent the opinion of Sun Microsystem, Inc. or any other party.