MySQL Forums
Forum List  »  MySQL Workbench

Creating new plugin fails (multiple issues)
Posted by: Karsten Wutzke
Date: March 10, 2024 07:42AM

Open MySQL WB, go to menu Scripting -> Scripting Shell (new window appearing).

Right-click in File Browser to the left -> Add New File (dialog opening).

Select "Python Plugin" -> choose "Generic Plugin" from radio items, leave default names. Then click "Create".

A new tab appears with the default name "myplugin_grt.py" (having an asterisk). Save using Ctrl+S. The new plugin file now appears in the File Browser to the left.

The debugger panel below says:

"Script saved as C:\Users\Kawu\AppData\Roaming\MySQL\Workbench\scripts\myplugin_grt.py
"

The new plugin file has the following contents:

--

# MySQL Workbench Plugin
# <description>
# Written in MySQL Workbench 8.0.36

from wb import *
import grt
#import mforms

ModuleInfo = DefineModule(myplugin, author="Author Name", version="1.0", description="Contains Plugin myplugin")

# This plugin takes no arguments
@ModuleInfo.plugin(myplugin, caption="Caption", description="description", input=[wbinputs.currentModel()], pluginMenu="Utilities")
@ModuleInfo.export(grt.INT)
def myplugin():
# Put plugin contents here
return 0

--

Now click on the lightning button in the toolbar saying "Execute script".

This results in:

"> run
Uncaught exception while executing C:\Users\Kawu\AppData\Roaming\MySQL\Workbench\scripts\myplugin_grt.py:
File "<string>", line 9, in <module>
NameError: name 'myplugin' is not defined"

It's kinda obvious this cannot work. The plugin name must be a string (on line 9 and line 12 respectively).

--

# MySQL Workbench Plugin
# <description>
# Written in MySQL Workbench 8.0.36

from wb import *
import grt
#import mforms

ModuleInfo = DefineModule("myplugin", author="Author Name", version="1.0", description="Contains Plugin myplugin")

# This plugin takes no arguments
@ModuleInfo.plugin("myplugin", caption="Caption", description="description", input=[wbinputs.currentModel()], pluginMenu="Utilities")
@ModuleInfo.export(grt.INT)
def myplugin():
# Put plugin contents here
return 0

--

Now running this results in:

"> run
Execution finished"

Before return 0 if I enter:

print("Here I am!")

executing the script outputs:

"> run
Execution finished"

Where's the output of my print statement? Why is nothing being output?

BTW, this is really embarassing WB guys...

Regards
Karsten

Options: ReplyQuote


Subject
Views
Written By
Posted
Creating new plugin fails (multiple issues)
282
March 10, 2024 07:42AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.