Quantcast
Channel: MySQL Forums - MySQL Workbench
Viewing all articles
Browse latest Browse all 3739

Scripting: Creating a script for forward engineering a SQL create script (2 replies)

$
0
0
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?

Viewing all articles
Browse latest Browse all 3739

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>