MySQL Forums
Forum List  »  MySQL Workbench

Scripting: Creating a script for forward engineering a SQL create script
Posted by: Johomoiny Bluff
Date: April 07, 2016 03:25PM

I'd like to take advantage of the scripting abilities of MySQLWorkbench, but I'm having a hard time finding documentation. My first script would be automatically building a SQL create script. Around the internet the following script (with small variations) is shows up a lot of places:

```
# -*- coding: utf-8 -*-
# MySQL Workbench Python script
# Dump database to SQL file
# Written in MySQL Workbench 6.3.6

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, {})
```

This is a good start--a create script is indeed generated, however, it includes dropping tables before creating them (instead of CREATE IF NOT EXISTS).

I can find no documentation of the third argument (options) to DbMySQLFE.generateSQLCreateStatements. Furthermore, changing the value of 'GenerateDrops' to 0, false or anything else doesn't seem to have any effect on the generated file. In fact, I see no effect of changing *any* of the options.

Where can I find documentation? Is the source available somewhere?

Options: ReplyQuote


Subject
Views
Written By
Posted
Scripting: Creating a script for forward engineering a SQL create script
1933
April 07, 2016 03:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.