PDMHandler
Power Designer是常见的数据库建模工具。本程序是一个使用python编写的工具类,用于处理power designer的数据文件。目前特性还不多,初步具备处理power designer模型文件(.pdm)的基本能力。
源码简介
PDMHandler.py
PDMHandler工具类的实现源码。使用下面的命令可以看到API的帮助文档(中文编写):
$ echo "import PDMHandler; help(PDMHandler);"|python
example1.py
PDMHandler类的一个使用示例,可用于编码参考。
源码地址:git@github.com:petjiang/PDMHandler.git
20150504:更新README.md
PDMHandler
Power Designer is usually used as a database modeling toolkit. This code implement a tool class to handle sybase PowerDesigner datafile(.pdm). Currently, it is able to handle power designer model file encode in .pdm files.
Source Code Intro.
PDMHandler.py
The class implementation of PDMHandler. use following command to see help docs (sorry that I type it in Chinese):
$ echo "import PDMHandler; help(PDMHandler);"|python
TEST PDM files
PowerDesigner model file (.pdm) is prepared in [repodir]/src/testpdm use these as input argument for testing the example1.py
NOTICE: (.pdm) files come from PowerDesigner15 directory [Sybase\PowerDesigner 15\Examples]
example1.py
It is a usecase of PDMHandler class, read it as a reference code.
example1.py shows 5 levels of pdm file -- Package/Table/Column/Index/IndexColumn
each level has their own attributes which are defined in PDMHandler class :
PKG_ATTR_LIST=["Name","Code","CreationDate","Creator","ModificationDate","Modifier"]
TBL_ATTR_LIST=["Name","Code","CreationDate","Creator","ModificationDate","Modifier", "PhysicalOptions"]
COL_ATTR_LIST=["Name","Code","CreationDate","Creator","ModificationDate","Modifier", "DataType","Length","Column.Mandatory","Comment"]
IDX_ATTR_LIST=["Name","Code","CreationDate","Creator","ModificationDate","Modifier", "PhysicalOptions","Unique"]
IDXCOL_ATTR_LIST=["CreationDate","Creator","ModificationDate","Modifier"]
By running :
$ python example1.py testpdm/Consol.pdm
shows the output to standout :
P: Duplicated Database DUPLICATED_DATABASE lpommier
T: Duplicated Account DUPLICATED_ACCOUNT vaudino
T-PATH: /Model/o:RootObject/c:Children/o:Model/c:Tables/o:Table
C: Email EMAIL char(256) 256 1
C: Name NAME char(256) 256
C: URL URL char(256) 256
I: ACCOUNT_PK ACCOUNT_PK 1
IC: EMAIL
T: Duplicated Auteurs DUPLICATED_AUTEURS vaudino
T-PATH: /Model/o:RootObject/c:Children/o:Model/c:Tables/o:Table
C: Email EMAIL char(256) 256 1
C: Title TITLE char(256) 256 1
I: AUTEURS_PK AUTEURS_PK 1
IC: EMAIL
IC: TITLE
I: Publication_FK PUBLICATION_FK
IC: EMAIL
I: Authors_FK AUTHORS_FK
IC: TITLE
T: Duplicated Publication DUPLICATED_PUBLICATION vaudino
T-PATH: /Model/o:RootObject/c:Children/o:Model/c:Tables/o:Table
C: Title TITLE char(256) 256 1
C: Email EMAIL char(256) 256 1
C: Pub_Title PUB_TITLE char(256) 256
C: Summary SUMMARY long varchar
C: Keywords KEYWORDS char(256) 256
I: PUBLICATION_PK PUBLICATION_PK 1
IC: TITLE
I: PUBLISHER_FK PUBLISHER_FK
IC: EMAIL
I: REFERENCES_FK REFERENCES_FK
IC: PUB_TITLE
Why I write it ?
Yes,it is just a tiny code for fun. But I hope more features will be added in it, and it will be useful to solve some headachy problem. Just like :
compare the online database instance with PDM file.
autogen SQL schema from PDM file (PowerDesigner's auto-gen setting sucks)
autogen ORM fro PDM file (seems awesome?!,support embed c,SQLAlchemy..)