I'm currently using FinalBuilder to create a one-click building n’ generate install, but I faced with MySQL Workbench lack of capacity to generate SQL script from a command line.
Asked
Active
Viewed 4,652 times
5
-
Please could you clarify why that is a problem and what you are trying to do? – cEz Jul 13 '10 at 21:35
-
Without Workbench's command line capacity, how can I automate the building operation? – Gedean Dias Jul 13 '10 at 22:19
-
What are you using Workbench for? It doesn't have a command line interface as far as I am aware. – cEz Jul 15 '10 at 11:33
-
mysql has a command line though, which is probably what he's referring to – Riot Goes Woof Jul 29 '13 at 15:12
2 Answers
4
You can actually automate this task with Python (or Lua) script - MySQL Workbench already has an interpreter under Scripting
menu. Create a new script and use the stub:
# -*- coding: utf-8 -*-
import os
import grt
from grt.modules import DbMySQLFE
c = grt.root.wb.doc.physicalModels[0].catalog
DbMySQLFE.generateSQLCreateStatements(c, c.version, {
'GenerateDrops' : 1,
'GenerateSchemaDrops' : 1,
'OmitSchemata' : 1,
'GenerateUse' : 1
})
DbMySQLFE.generateSQLCreateStatements(c, c.version, {
DbMySQLFE.createScriptForCatalogObjects(os.path.dirname(grt.root.wb.docPath) + 'ddl.sql', c, {})
It does not actully run from command line, but I beleive you can run it with --run-script
option.

madhead
- 31,729
- 16
- 153
- 201
-
2Thanks ! This basically works (and I have incorporated your answer into [my question's answer](http://stackoverflow.com/a/26914679/419404) as well), though there are some minor errors in your script: It should read `DbMySQLFE.generateSQLCreateStatements(c, c.version, {})` and `+ '/ddl.sql'`. – Arc Nov 13 '14 at 17:23
0
MySQL Workbench has a full Python Scripting API.
If you need additional features, please let us know: http://forums.mysql.com/index.php?151
- MySQL Workbench
-
2Tnx for the link. I will surely check this API out. It'd be definitely a cool feature to have a CLI app also, which could generate SQL from mwb files. So DB schemas could be designed using the MySQL Workbench GUI, and then a single click automated deployment procedure (during development, I mean) could do everything on the db schema. Keeping everything DRY compliant. But I'm confident this can all be done through the Python API mentioned above. – maraspin Dec 10 '10 at 11:07