5

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.

4
  • Please could you clarify why that is a problem and what you are trying to do? Commented Jul 13, 2010 at 21:35
  • Without Workbench's command line capacity, how can I automate the building operation? Commented 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. Commented Jul 15, 2010 at 11:33
  • mysql has a command line though, which is probably what he's referring to Commented Jul 29, 2013 at 15:12

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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'.
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

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.