PowerDesigner文件解析的python api工具类实现
PowerDesigner文件解析的python api工具类实现
realpeter 发表于3年前
PowerDesigner文件解析的python api工具类实现
  • 发表于 3年前
  • 阅读 54
  • 收藏 0
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

摘要: power designer python xml

PDMHandler

Power Designer是常见的数据库建模工具。本程序是一个使用python编写的工具类,用于处理power designer的数据文件。目前特性还不多,初步具备处理power designer模型文件(.pdm)的基本能力。

源码简介

PDMHandler.py

PDMHandler工具类的实现源码。使用下面的命令可以看到API的帮助文档(中文编写):

$ echo "import PDMHandler; help(PDMHandler);"|python

example1.py

PDMHandler类的一个使用示例,可用于编码参考。

项目主页:https://github.com/petjiang/PDMHandler

源码地址:git@github.com:petjiang/PDMHandler.git


20150504:更新README.md 

(https://github.com/petjiang/PDMHandler/blob/master/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..)


共有 人打赏支持
粉丝 0
博文 1
码字总数 584
×
realpeter
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: