Nov 5, 2017

Run Python script in MySQL Workbench

Run Python script in MySQL Workbench

  1. Start MySQLWorkbench
  2. connect to local database
  3. select sakila from SCHEMAS
  4. start scripting shell with Tools->scripting shell or (Ctrl+F3)
  5. Add new python script (test.py)
  6. Save script with the content below
  7. run script in scripting shell

# -*- coding: utf-8 -*-
# MySQL Workbench Python script
# <description>
# Written in MySQL Workbench 6.3.6

import grt
#import mforms
result = grt.root.wb.sqlEditors[0].executeScript("select * from contacts limit 8;")

for col in result[0].columns:
    print col.name