Bug #66451 Workbench Scripting Shell can't handle indented commands
Submitted: 19 Aug 2012 5:42 Modified: 13 Mar 2014 5:09
Reporter: Michael McLaughlin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S2 (Serious)
Version:5.2.42 OS:Any
Assigned to: CPU Architecture:Any
Tags: MySQL Workbench Script Shell

[19 Aug 2012 5:42] Michael McLaughlin
Description:
When you try to dynamically type a script in the MySQL Workbench Scripting Shell indentation causes an IndentationError error. This effectively means you can't use loops or conditional statements.

The Severity may be less than Serious because there is a work around. I leave that to the bug triage team.

The work around to the lack of this feature is that you can put the logic in a script file, save the script file, and run the script file to test the logic. Although, it seems an interactive Python-like shell should work like the regular Python command-line.

How to repeat:
Type the following in the MySQL Workbench Scripting Shell

>>> import os
>>> f = open("c:\\Data\\MySQL\\query.sql",'rU')
>>> while True:
...     line = f.readline()
...     if not line[len(line) - 1:len(line)] == ";":
  File "<string>", line 3
    if not line[len(line) - 1:len(line)] == ";": 
                                               ^

IndentationError: expected an indented block

Suggested fix:
Fix the parser to allow tabs or spaces for indentation of interactive Python scripts.
[19 Aug 2012 7:08] Valeriy Kravchuk
Thank you for the bug report. Verified on Mac OS X also.
[13 Mar 2014 5:09] Philip Olson
Fixed as of the upcoming MySQL Workbench 6.1.3 release, and here's the changelog entry:

The "MySQL Workbench Scripting Shell" did not allow tabs or spaces for
indentation in interactive Python scripts. A workaround was to instead
create and execute script files.

Thank you for the bug report.