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.
-
Please could you clarify why that is a problem and what you are trying to do?cEz– cEz2010-07-13 21:35:24 +00:00Commented Jul 13, 2010 at 21:35
-
Without Workbench's command line capacity, how can I automate the building operation?Gedean Dias– Gedean Dias2010-07-13 22:19:23 +00:00Commented Jul 13, 2010 at 22:19
-
What are you using Workbench for? It doesn't have a command line interface as far as I am aware.cEz– cEz2010-07-15 11:33:14 +00:00Commented Jul 15, 2010 at 11:33
-
mysql has a command line though, which is probably what he's referring toTango Bloom– Tango Bloom2013-07-29 15:12:41 +00:00Commented Jul 29, 2013 at 15:12
Add a comment
|
2 Answers
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.
1 Comment
Arc
Thanks ! This basically works (and I have incorporated your answer into my question's answer as well), though there are some minor errors in your script: It should read
DbMySQLFE.generateSQLCreateStatements(c, c.version, {}) and + '/ddl.sql'.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
1 Comment
maraspin
Tnx 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.