viernes, 14 de abril de 2017

Generating a script for FirebirdSQL from MySQLWorkbench


 MySQLWorkbench allows to design database model easily and also provides an option to generate the SQL script.   By default script is generated for MySQL, but, what if you need to generate a SQL script for FirebirdSQL?.

Using Python you cand create custom plugins to access to model properties  (table and columns definitions for example) please visit this link for more info Scripting and Plugin Development

So, I decided to write a plugin to generate a SQL Script for FirebirdSQL. My goal it's just to show how can we access to schemas, tables and columns properties using classes already defined by MySQLWorkbench.

Script can be downloaded from github: https://github.com/tmsanchez/workbenchscripts/blob/master/mysqlToFB_grt.py
 
Note an for MySQLWorkbench 8.x check this http://tmsanchezdev.blogspot.com/2021/05/updated-plugings-for-mysqlworkbench-8x.html

Once script is downloaded do following:

1. Go to menu: Script / Install Plugin Module...
2. In Select Module to Install select mysqlToFB_grt.py and clic on Open
 
 3. Clic on OK button on Plugin Installed dialog and Restart MySQL
4. Open your model and go to menu Tools / Catalog / Database schema to Firebird Script
5. Provide an filename for the script in the Save Dialog and clic Save Button
6. Once script was generated clic OK button on following dialog



That's all, I hope this can help you to generate Firebird scripts and to write your own plugins.