Erwin API with Python

1.5k views Asked by At

I am trying to get clear concept on how to get the Erwin generated DDL objects with python ? I am aware Erwin API needs to be used. What i am looking if what Python Module and what API needs to used and how to use them ? I would be thankful for some example !

2

There are 2 answers

0
Jeff Fletcher On

Here is a start: import win32com.client

ERwin = win32com.client.Dispatch("erwin9.SCAPI")

I haven't been able to browse the scapi dll so what I know is from trial and error. Erwin publishes VB code that works, but it is not straightforward to convert.

0
miazo On

Install pywin32 (run the below from pip folder e.g. c:\Program Files\Python37\Scripts)

python -m pip install pywin32
python pywin32_postinstall.py -install

Sample script to extract DDL using Erwin's Forward Engineer functionality (change paths accordingly):

import win32com.client
api = win32com.client.Dispatch("erwin9.SCAPI")
unit = api.PersistenceUnits.Add("c:/models/data_model.erwin", "RDO=Yes")
unit.FEModel_DDL("c:/scripts/ddl_script.sql")

For the above to work, Erwin application should be running (probably).