C.5.2 Shell 視窗

Workbench 指令碼 Shell 主要用於執行 Python 指令碼,或直接在 Python 中輸入命令。然而,您也可以使用它來存取 Workbench 指令碼 Shell 指令碼庫函式和全域函式和物件。若要查看可用的命令,請輸入 ?。您也可以剪下並貼上文字到 Shell 視窗或從 Shell 視窗剪下文字。

程式碼片段索引標籤是儲存程式碼片段的草稿板,方便您在 MySQL Workbench 中重複使用和執行程式碼。下圖顯示選取的「程式碼片段」索引標籤。

圖 C.2:Workbench 指令碼 Shell:程式碼片段

Content is described in the surrounding text.

已開啟的指令碼檔案索引標籤位於程式碼片段索引標籤的右側。指令碼索引標籤會標示指令碼的檔案名稱,或未命名的程式碼片段則標示為 未命名。您可以剪下並貼上到索引標籤或從索引標籤剪下,或以滑鼠右鍵按一下程式碼片段以開啟內容功能表,其中包含執行程式碼片段傳送到指令碼編輯器複製到剪貼簿的選項。

雖然可以在 Shell 中輸入個別命令,但也可以使用主功能表項目指令碼執行 Workbench 指令碼檔案來執行儲存在外部檔案中的較長指令碼。當指令碼在 Shell 外執行時,若要查看輸出,請使用主功能表項目檢視輸出

也可以直接從 Shell 執行指令碼檔案。如需執行指令碼檔案的詳細資訊,請在 Workbench 指令碼 Shell 提示字元中輸入 ? run。會顯示下列訊息

Help Topics
-----------
grt        General information about the Workbench runtime
scripting  Practical information when working on scripts and modules for Workbench
wbdata     Summary about Workbench model data organization
modules    Information about Workbench module usage
plugins    Information about writing Plugins and Modules for Workbench
Type '? [topic]' to get help on the topic.

Custom Python Modules
---------------------
   grt         Module to work with Workbench runtime (grt) objects
   grt.root    The root object in the internal Workbench object hierarchy
   grt.modules Location where Workbench modules are available
   grt.classes List of classes known to the GRT system
   mforms      A Module to access the cross-platform UI toolkit used in some Workbench features
   wb          Utility module for creating Workbench plugins

Type 'help(module/object/function)' to get information about a module, object or function.
Type 'dir(object)'                  to get a quick list of methods an object has.

For an introductory tutorial on the Python language,    visit http://docs.python.org/tutorial/
For general Python and library reference documentation, visit http://python.org/doc/

在 Workbench 指令碼 Shell 中,左側面板頂端有五個索引標籤:檔案全域類別模組通知

注意

嘗試使用 input() 或從 stdin 讀取時,會擲回例外狀況。