#!/usr/bin/python # -*- coding: utf-8 -*- # from PDMHandler import PDMHandler if __name__ == '__main__': import sys reload(sys) sys.setdefaultencoding("utf-8") if len(sys.argv) <= 1: print("USAGE: ", sys.argv[0], "<filename>") print("EXAMPLE: ", sys.argv[0], "data/Consol.pdm") sys.exit(1) else: filename = sys.argv[1] ph = PDMHandler.parse(filename) for pkg in PDMHandler.getPkgNodes(ph): pkg_attrs = PDMHandler.getPkgAttrs(pkg) print "P:", pkg_attrs["Name"], pkg_attrs["Code"], pkg_attrs["Creator"] for tbl in PDMHandler.getTblNodesInPkg(pkg): tbl_attrs = PDMHandler.getTblAttrs(tbl) print " T:", tbl_attrs["Name"], tbl_attrs["Code"], tbl_attrs[ "Creator"] print " T-PATH:", PDMHandler.getNodePath(tbl) for col in PDMHandler.getColNodesInTbl(tbl): col_attrs = PDMHandler.getColAttrs(col) print " C:", col_attrs["Name"], col_attrs["Code"], col_attrs[ "DataType"], col_attrs["Length"], col_attrs[ "Column.Mandatory"] for idx in PDMHandler.getIdxNodesInTbl(tbl): idx_attrs = PDMHandler.getIdxAttrs(idx) print " I:", idx_attrs["Name"], idx_attrs["Code"], idx_attrs[
import sys, time, string, re reload(sys) sys.setdefaultencoding("utf-8") if len(sys.argv) <= 1: print "USAGE: ",sys.argv[0],"<filename>","[tablename]" print "EXAMPLE 1: ",sys.argv[0],"data/Consol.pdm" print "EXAMPLE 2: ",sys.argv[0],"data/Consol.pdm","UserTable" sys.exit(1) else: filename = sys.argv[1] if len(sys.argv) >= 3: tablename = sys.argv[2] else: tablename = "" try: ph = PDMHandler.parse(filename) except: sys.exit(1) filename = "dbentity.jh" output=sys.stdout outputfile=open("src/"+filename,'w') sys.stdout=outputfile x = time.localtime() print "/*" print "*",filename print "*" print "* Created Date:",time.strftime('%Y-%m-%d %H:%M:%S',x) print "*" print "* Copyright (c) Centling Technologies Co., Ltd."
#!/usr/bin/python # -*- coding: utf-8 -*- # from PDMHandler import PDMHandler if __name__ == '__main__': import sys reload(sys) sys.setdefaultencoding("utf-8") if len(sys.argv) != 2: print "USAGE: ", sys.argv[0], "<filename>" print "EXAMPLE: ", sys.argv[0], "testpdm/Consol.pdm" sys.exit(1) else: filename = sys.argv[1] ph = PDMHandler.parse(filename) for pkg in PDMHandler.getPkgNodes(ph): pkg_attrs = PDMHandler.getPkgAttrs(pkg) for tbl in PDMHandler.getTblNodesInPkg(pkg): tbl_attrs = PDMHandler.getTblAttrs(tbl) print "CREATE TABLE", tbl_attrs["Code"], "\n(" cols = PDMHandler.getColNodesInTbl(tbl) for col in cols: col_attrs = PDMHandler.getColAttrs(col) print " ", "%-16s " % col_attrs["Code"], "%-16s" % col_attrs[ "DataType"], if col_attrs["Column.Mandatory"] == "1": print "NOT NULL", else: print " ", if cols.index(col) != len(cols) - 1: print "," else: print "\n);" for idx in PDMHandler.getIdxNodesInTbl(tbl): idx_attrs = PDMHandler.getIdxAttrs(idx)
#!/usr/bin/python # -*- coding: utf-8 -*- # from PDMHandler import PDMHandler if __name__ == '__main__' : import sys reload(sys) sys.setdefaultencoding("utf-8") if len(sys.argv) != 2: print "USAGE: ",sys.argv[0],"<filename>" print "EXAMPLE: ",sys.argv[0],"testpdm/Consol.pdm" sys.exit(1) else: filename = sys.argv[1] ph = PDMHandler.parse(filename) for pkg in PDMHandler.getPkgNodes(ph): pkg_attrs = PDMHandler.getPkgAttrs(pkg) for tbl in PDMHandler.getTblNodesInPkg(pkg) : tbl_attrs = PDMHandler.getTblAttrs(tbl) print "CREATE TABLE",tbl_attrs["Code"],"\n(" cols = PDMHandler.getColNodesInTbl(tbl) for col in cols : col_attrs = PDMHandler.getColAttrs(col) print " ", "%-16s "%col_attrs["Code"], "%-16s"%col_attrs["DataType"], if col_attrs["Column.Mandatory"] == "1" : print "NOT NULL", else: print " ", if cols.index(col) != len(cols) - 1 : print "," else : print "\n);" for idx in PDMHandler.getIdxNodesInTbl(tbl) : idx_attrs = PDMHandler.getIdxAttrs(idx) if idx_attrs["Unique"] == "1" : print "CREATE UNIQUE INDEX %s \n("%idx_attrs["Code"]