How to generate insert statements and exclude some tables when forward engineering a database schema in MySQL Workbench with a python script? -
my goal generate database schema console, while generating insert statements , excluding single table.
here code have an answer similar question (slightly modified):
import os import grt grt.modules import dbmysqlfe c = grt.root.wb.doc.physicalmodels[0].catalog dbmysqlfe.generatesqlcreatestatements(c, c.version, { 'generateinserts' : 1, }) # http://unix.stackexchange.com/a/308666/67375 stdout = '/proc/' + str(os.getpid()) + '/fd/1' dbmysqlfe.createscriptforcatalogobjects(stdout, c, {})
when run:
mysql-workbench \ ${mysql_workbench_file} \ --run "`cat the-script-above.py`" \ --quit-when-done
this outputs database schema stdout, but
'generateinserts': 1
nothing, other key-value pairs tried put there after browsing mysql-workbench's source code. resulting sql code doesn't contain insert statements;- i don't know start excluding 1 of tables resulting sql code.
i can generate required schema using gui in mysql-workbench, automate this.
Comments
Post a Comment