db2text 0.2.4__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {db2text-0.2.4 → db2text-0.3.1}/MANIFEST.in +1 -0
  2. {db2text-0.2.4/db2text.egg-info → db2text-0.3.1}/PKG-INFO +1 -1
  3. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/dbtmanual.md +13 -3
  4. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/dot.mb +28 -26
  5. db2text-0.3.1/db2text/datafile/sample/oceanbase/all.txt +41 -0
  6. db2text-0.3.1/db2text/datafile/sample/oceanbase/sjbf.txt +20 -0
  7. db2text-0.3.1/db2text/datafile/sample/oracle/cc.txt +25 -0
  8. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/oracle/crmrpt.txt +1 -1
  9. db2text-0.3.1/db2text/datafile/sample/oracle/sms.txt +21 -0
  10. db2text-0.3.1/db2text/db/ob_oracle.py +145 -0
  11. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/oracle11.py +3 -1
  12. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/dbt.py +6 -6
  13. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/tool.py +1 -1
  14. {db2text-0.2.4 → db2text-0.3.1/db2text.egg-info}/PKG-INFO +1 -1
  15. db2text-0.3.1/db2text.egg-info/SOURCES.txt +37 -0
  16. db2text-0.3.1/db2text.egg-info/entry_points.txt +3 -0
  17. {db2text-0.2.4 → db2text-0.3.1}/db2text.egg-info/not-zip-safe +0 -0
  18. db2text-0.3.1/db2text.egg-info/top_level.txt +1 -0
  19. {db2text-0.2.4 → db2text-0.3.1}/setup.py +3 -3
  20. db2text-0.2.4/db2text/db/__init__.py +0 -1
  21. db2text-0.2.4/db2text.egg-info/SOURCES.txt +0 -33
  22. db2text-0.2.4/db2text.egg-info/entry_points.txt +0 -3
  23. db2text-0.2.4/db2text.egg-info/top_level.txt +0 -2
  24. {db2text-0.2.4 → db2text-0.3.1}/LICENSE +0 -0
  25. {db2text-0.2.4 → db2text-0.3.1}/README.md +0 -0
  26. {db2text-0.2.4 → db2text-0.3.1}/db2text/__init__.py +0 -0
  27. {db2text-0.2.4 → db2text-0.3.1}/db2text/data.py +0 -0
  28. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/dbt_dot_mssql.txt +0 -0
  29. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/dm/all.txt +0 -0
  30. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/mysql/all.txt +0 -0
  31. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/mysql/wiki.txt +0 -0
  32. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/opengauss/all.txt +0 -0
  33. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/oracle/all.txt +0 -0
  34. {db2text-0.2.4/database2text → db2text-0.3.1/db2text}/datafile/sample/sqlserver/all.txt +0 -0
  35. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/__init__.py +0 -0
  36. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/dm.py +0 -0
  37. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/mssql.py +0 -0
  38. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/mysql.py +0 -0
  39. {db2text-0.2.4/database2text → db2text-0.3.1/db2text/db}/opengauss.py +0 -0
  40. {db2text-0.2.4 → db2text-0.3.1}/db2text/util.py +0 -0
  41. {db2text-0.2.4 → db2text-0.3.1}/db2text.egg-info/dependency_links.txt +0 -0
  42. {db2text-0.2.4 → db2text-0.3.1}/db2text.egg-info/requires.txt +0 -0
  43. {db2text-0.2.4 → db2text-0.3.1}/setup.cfg +0 -0
@@ -1 +1,2 @@
1
1
  recursive-include database2text/datafile *
2
+ recursive-include db2text/datafile *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: db2text
3
- Version: 0.2.4
3
+ Version: 0.3.1
4
4
  Summary: database to text
5
5
  Home-page: https://gitee.com/chenc224/dbt
6
6
  Author: Chen chuan
@@ -28,6 +28,8 @@ struct stru_note_request {//消息请求队列 note_request
28
28
  | tjsj | datetime | | | 提交时间 |
29
29
  | clff | varchar(50) | 可 | | 处理方法 |
30
30
 
31
+ * 根据指定格式,把数据库结构等更新到mediawiki中,几乎无成本的使文档可以跟踪最新的结构变化。
32
+
31
33
  还有一个部分就是提供一个库,方便大家解析数据库,获取数据结构,进行一些自己的处理。dbt命令行工具可以认为就是用这个库写出来的一个应用吧。
32
34
 
33
35
  ## 安装
@@ -79,11 +81,15 @@ table= + abcd.*
79
81
 
80
82
  指定连接到哪种数据库,根据数据库的不同,后续的参数会有差异。具体参数可以参考样例文件。样例文件可以在https://gitee.com/chenc224/dbt/tree/master/database2text/datafile/sample 下察看。
81
83
 
82
- 增加使用dbcfg方法,这里的配置就容易一些,只用一行比如
84
+ 建议使用dbcfg方法,这里的配置就容易一些,只用一行比如
83
85
 
84
86
  `dbcfg=mysql234`
85
87
 
86
- 就可以了,后续会自动使用dbcfg来进行数据库连接。注意如果没有设置driver,则使用dbcfg设置中的db内容来作为driver使用。
88
+ 就可以了,后续会自动使用dbcfg来进行数据库连接。
89
+
90
+ 使用dbcfg可以不用设置driver,会用dbcfg设置中的db内容来作为driver使用。
91
+
92
+ dbcfg相关设置参考https://gitee.com/chenc224/dbcfg/blob/master/README.md
87
93
 
88
94
  ## readdata段
89
95
  读入数据库结构,具体数据格式细节随驱动器不同会有差异。
@@ -149,6 +155,10 @@ page设置的是页名称列表,每个页名称对应一个设置项,other
149
155
 
150
156
  每个页名称会生成一页pdf,最终合成得到一个多页的pdf。如果不需要多页pdf,可以不用设置page语句。
151
157
 
158
+ autosplit= 50
159
+
160
+ 自动分页设置,每多少个字段则自动分下一页
161
+
152
162
  ## wiki段
153
163
 
154
164
  生成wiki里的表格。如果指定wiki,可以直接用wiki机器人自动更新wiki内容。如果不指定wiki,则输出文本内容供粘贴。
@@ -196,7 +206,7 @@ level = 2 如果是一张新表,会在内容的最后增加这个表格,在
196
206
 
197
207
  # 设计思路
198
208
 
199
- dbt执行时根据dbt.txt里的内容执行相应处理。主要流程就是连接数据库、读取数据库结构、导出结构或者根据结构调整文本。这里连接数据库、读取数据库结构考虑设计成模块化的,这样可以方便替换不同的数据库。后续导出结构或者根据结构调整文本其实不同的数据库是基本类似的,差异可能只是数据结构有不同,所以这一部分设计成通用的。
209
+ dbt执行时根据dbt.txt里的内容执行相应处理。主要流程就是连接数据库、读取数据库结构、导出结构或者根据结构调整文本。这里连接数据库、读取数据库结构考虑设计成模块化的,方便替换不同的数据库。后续导出结构或者根据结构调整文本其实不同的数据库是基本类似的,差异可能只是数据结构有不同,所以这一部分设计成通用的。
200
210
 
201
211
  ## db2text 模块
202
212
 
@@ -1,26 +1,28 @@
1
- graph 表结构 {
2
- size = "8.5,11";
3
- margin=0;
4
- pad=0.1;
5
- page="8.5,11";
6
- # charset=utf8;
7
- ratio="fill"
8
- # dpi = 300
9
- # rankdir = "TR"
10
- # node[shape=record fontname="wqy-zenhei" size="30,30"]
11
- node[shape=plaintext fontname="wqy-zenhei"]
12
-
13
- {% for t in TABLE %}
14
- {{ t.tname }} [
15
- label=<
16
- <table border="1" cellborder="0">
17
- <tr><td colspan="3">{{ t.tdesc }} {{ t.tname }}</td></tr>
18
- {%- for c in t.md %}
19
- <tr><td align="left">{{ c.desc }}</td><td align="left">{{ c.pk and '<u>' or ''}}{{ c.name }}{{ c.pk and '</u>' or ''}}</td><td align="left">{{ c.ts }}</td></tr>
20
- {%- endfor %}
21
- </table>
22
- >
23
- ]
24
- {% endfor %}
25
-
26
- }
1
+ #模板文件,用于生成graphviz文件,再生成pdf
2
+
3
+ graph 表结构 {
4
+ size = "8.27,11.69";
5
+ margin=0;
6
+ pad=0.1;
7
+ page="8.27,11.69";
8
+ # charset=utf8;
9
+ ratio="fill"
10
+ # dpi = 300
11
+ # rankdir = "TR"
12
+ # node[shape=record fontname="wqy-zenhei" size="30,30"]
13
+ node[shape=plaintext fontname="wqy-zenhei"]
14
+
15
+ {% for t in TABLE %}
16
+ {{ t.tname }} [
17
+ label=<
18
+ <table border="1" cellborder="0">
19
+ <tr><td colspan="3">{{ t.tdesc }} {{ t.tname }}</td></tr>
20
+ {%- for c in t.md %}
21
+ <tr><td align="left">{{ c.desc }}</td><td align="left">{{ c.pk and '<u>' or ''}}{{ c.name }}{{ c.pk and '</u>' or ''}}</td><td align="left">{{ c.ts }}</td></tr>
22
+ {%- endfor %}
23
+ </table>
24
+ >
25
+ ]
26
+ {% endfor %}
27
+
28
+ }
@@ -0,0 +1,41 @@
1
+ #基础说明可参考https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/usermenual.md
2
+ #sample for oceanbase
3
+ #oceanbase的样例文件
4
+ #号开头的行为注释,并不需要处理
5
+ #冒号开头的行表示一段内容的开始,直到另外一个冒号或者是文件尾
6
+ #执行时扫描配置文件,把每一段的内容传递给相应的处理函数处理
7
+ :connect
8
+
9
+ dbcfg=jyzt
10
+
11
+ :readdata
12
+
13
+ :export
14
+ #export段设置导出数据库里的相应内容为文本文件
15
+ datadir=local/oceanbase/export
16
+
17
+ :render
18
+ file=local/oceanbase/all.md
19
+ help=n
20
+ #使用help=y可以打印出传入模板的数据,方便写模板的时候使用
21
+ #下面是模板样例,jinja2模板库,这个样例是根据表定义一个c语言的结构,用于pro*c使用
22
+ start=## {{ tname }}
23
+ ## {{ tname }} {{ tdesc }}
24
+ | 字段名 | 类型 | 长度 | 空 | 默认值 | 说明 |
25
+ | :---- | :---- | ----: | :---- | :---- | :---- |
26
+ {% for c in ori %}| {{ c.COLUMN_NAME }} | {{ c.DATA_TYPE }} | {{ c.DATA_LENGTH }} | {% if c.NULLABLE == "Y" %}可{% endif %} | {{ c.DATA_DEFAULT or "" }} | {{ c.COLUMN_COMMENT }} |
27
+ {% endfor %}
28
+ end=
29
+
30
+ #根据模板生成dot文件,调用neato生成pdf文件
31
+ :dot
32
+ #cmd=neato -Tpdf test/oracle/all.dot -o local/oracle/alldot.pdf
33
+ dotdir=local/oceanbase
34
+ pdfdir=local/oceanbase
35
+ filename=all
36
+ dotcmd=neato
37
+ #可以选择dot,neato,twopi,circo,fdp,sfdp,patchwork和osage指定graphviz布局算法
38
+
39
+ #dot生成多页pdf的例子
40
+
41
+ :end
@@ -0,0 +1,20 @@
1
+ # 数据备份相关表
2
+ :connect
3
+
4
+ dbcfg=sjbf
5
+
6
+ :readdata
7
+
8
+ :dot
9
+ dotdir=test/oceanbase
10
+ pdfdir=local/oceanbase
11
+ filename=sjbf
12
+ dotcmd=neato
13
+
14
+ :wiki
15
+ title = name:字段名 desc:注释 ts:类型 default:默认值 :说明
16
+ wiki=wiki
17
+ page=数据备份脚本
18
+ level=2
19
+
20
+ :end
@@ -0,0 +1,25 @@
1
+ #cc库模板文件
2
+
3
+ :connect
4
+
5
+ dbcfg=cc@cc
6
+
7
+ :readdata
8
+
9
+ # 系统监控用户
10
+ owner=XTJK
11
+
12
+
13
+ #根据模板生成dot文件,调用fdp生成pdf文件
14
+ :dot
15
+ dotdir=test/oracle
16
+ pdfdir=local/oracle
17
+ page=备份 其它
18
+ 备份= .*BF.*
19
+ filename=xtjk
20
+ dotcmd=fdp
21
+ #可以选择dot,neato,twopi,circo,fdp,sfdp,patchwork和osage指定graphviz布局算法
22
+ autosplit = 50
23
+ #每50行分一页
24
+
25
+ :end
@@ -1,4 +1,4 @@
1
- #基础说明可参考https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/usermenual.md
1
+ #基础说明可参考https://gitee.com/chenc224/dbt/blob/master/db2text/datafile/dbtmanual.md
2
2
  #sample for oracle 11
3
3
  #oracle11的样例文件
4
4
  #号开头的行为注释,并不需要处理
@@ -0,0 +1,21 @@
1
+ #cc库sms用户
2
+
3
+ :connect
4
+
5
+ dbcfg=cc@cc
6
+
7
+ :readdata
8
+
9
+ table= + .* - rtyg .*ygxx.* ye jjjkwj sztwj jjjkzd hm1231 hm2 rsts ygzj dxx20.*
10
+
11
+ #根据模板生成dot文件,调用fdp生成pdf文件
12
+ :dot
13
+ dotdir=test/oracle
14
+ pdfdir=local/oracle
15
+ filename=sms
16
+ dotcmd=fdp
17
+ #可以选择dot,neato,twopi,circo,fdp,sfdp,patchwork和osage指定graphviz布局算法
18
+ autosplit = 50
19
+ #每50行分一页
20
+
21
+ :end
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys,json
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
+
8
+ class oracle(object):
9
+ def ana_TABLE(otype):
10
+ for oname, in db.exec("select object_name from all_objects where object_type=:ot and owner=:owner order by 1",ot=otype,owner=owner):
11
+ if 检查匹配(otype,oname):
12
+ continue
13
+ if oname.startswith("SYS_EXPORT_TABLE"):
14
+ continue
15
+ odata="create table %s\n(\n" %(oname)
16
+ coldata=[] #记录列数据,包括type类型,name列名,desc注释信息,size长度,ns名称+长度如name[5]这样
17
+ md=[] #markdown等用的字段数据,每字段一个字典,包括 "name": 字段名,"desc": 注释,"type": 数据类型,"size":字段长度,"null":True of False,是否可为空,"default":默认值
18
+ maxcsize=db.res1("select max(length(column_name)) from all_tab_cols where owner='%s' and table_name='%s'" %(owner,oname))
19
+ tdesc=db.res1("select comments from all_tab_comments where owner=:1 and table_name=:2",[owner,oname])
20
+ if not tdesc:tdesc=""
21
+ oridata=[]
22
+ for col in db.exec2("select * from all_tab_cols where owner='%s' and table_name='%s' order by column_id" %(owner,oname)):
23
+ col["COLUMN_COMMENT"]=db.res1("select comments from all_col_comments where table_name=:1 and column_name=:2 and owner=:3",[oname,col["COLUMN_NAME"],owner])
24
+ if col["DATA_DEFAULT"]!=None:
25
+ col["DATA_DEFAULT"]=col["DATA_DEFAULT"].strip()
26
+ oridata.append(col)
27
+ for column_name,data_type,char_length,data_precision,data_scale,nullable,default_length,data_default in db.exec("select column_name,data_type,char_length,data_precision,data_scale,nullable,default_length,data_default from all_tab_cols where owner='%s' and table_name='%s' order by column_id" %(owner,oname)):
28
+ if data_default:
29
+ data_default=data_default.strip()
30
+ odata=odata+" %s%*s" %(column_name,maxcsize-len(column_name)+1," ")
31
+ ctype="char"
32
+ desc=db.res1("select comments from all_col_comments where table_name=:1 and column_name=:2 and owner=:3",[oname,column_name,owner])
33
+ if not desc:desc=""
34
+ if data_type=="NUMBER":
35
+ if data_precision is not None and data_scale is not None:
36
+ if data_scale==0:
37
+ if data_precision<8:ctype="int"
38
+ else:ctype="long"
39
+ odata=odata+"NUMBER(%d)" %(data_precision)
40
+ ts=f"NUMBER({data_precision})"
41
+ else:
42
+ ctype="double"
43
+ odata=odata+"NUMBER(%d,%d)" %(data_precision,data_scale)
44
+ ts=f"NUMBER({data_precision}.{data_scale})"
45
+ elif data_precision is None and data_scale==0:
46
+ ctype="long"
47
+ odata=odata+"INTEGER"
48
+ ts="INTEGER"
49
+ elif char_length==0:
50
+ ctype="long"
51
+ odata=odata+"NUMBER"
52
+ ts="INTEGER"
53
+ else:
54
+ print("table %s column %s type %s length %s %s %s" %(oname,column_name,data_type,char_length,data_precision,data_scale))
55
+ sys.exit(-1)
56
+ cns=column_name
57
+ elif data_type in ("VARCHAR2","VARCHAR","CHAR","NVARCHAR2","NVARCHAR"):
58
+ if char_length==1:
59
+ ts=data_type
60
+ else:
61
+ ts=f"{data_type}({char_length})"
62
+ cns="%s[%d]" %(column_name,char_length+1)
63
+ odata=odata+"%s(%d)" %(data_type,char_length)
64
+ elif data_type.startswith("TIMESTAMP"):
65
+ cns="%s[20]" %(column_name)
66
+ odata=odata+"%s" %(data_type)
67
+ ts=data_type
68
+ elif data_type in("DATE"):
69
+ cns="%s[20]" %(column_name)
70
+ odata=odata+"%s" %(data_type)
71
+ ts=data_type
72
+ elif data_type in("CLOB","BLOB","NCLOB","LONG","RAW"):
73
+ cns="%s[2000]" %(column_name)
74
+ odata=odata+"%s" %(data_type)
75
+ ts=data_type
76
+ elif data_type in ("FLOAT"):
77
+ ctype="double"
78
+ odata=odata+"FLOAT(%d)" %(data_precision)
79
+ ts=data_type
80
+ elif data_type in ("ROWID"):
81
+ cns="%s[100]" %(column_name)
82
+ odata=odata+"%s" %(data_type)
83
+ ts=data_type
84
+ else:
85
+ print("table %s column %s type %s length %s %s %s" %(oname,column_name,data_type,char_length,data_precision,data_scale))
86
+ sys.exit(-1)
87
+ if default_length:
88
+ odata=odata+" default %s" %(data_default)
89
+ if nullable=="N":
90
+ odata=odata+" not null"
91
+ odata=odata+",\n"
92
+ cns2=cns
93
+ if data_type in ("VARCHAR2","VARCHAR","CHAR","NVARCHAR2","NVARCHAR") and char_length==1:
94
+ cns=column_name
95
+ coldata.append({"type":ctype,"name":column_name,"ns":cns,"ns2":cns2,"desc":desc})
96
+ 主键列=[]
97
+ for pkcol, in db.exec(f"SELECT cols.column_name FROM user_constraints cons, user_cons_columns cols WHERE cons.constraint_type = 'P' AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner and cons.owner = '{owner}' AND cols.table_name = '{oname}'"):
98
+ 主键列.append(pkcol)
99
+ md.append({"name":column_name,"desc":desc,"type":data_type,"size":char_length, "null":nullable=="N", "default":data_default,"ts":ts, "pk":column_name in 主键列})
100
+ odata=odata[:-2]
101
+ odata=odata+"\n);"
102
+ dbdata["sql"]["TABLE"][oname]=odata
103
+ dbdata["exp"]["TABLE"].append({"tname":oname,"tdesc":tdesc,"ori":oridata,"c":coldata,"md":md})
104
+
105
+ def ana_VIEW(otype):
106
+ for oname, in db.exec("select object_name from user_objects where object_type=:ot",ot=otype):
107
+ if "view" in stdata and oname.lower() not in stdata["view"].split() and oname not in stdata["view"].split():
108
+ continue
109
+ dbdata["sql"][otype][oname]=oracle.getobjtext(otype,oname)
110
+
111
+ def getobjtext(otype,oname):
112
+ c=db.conn.cursor()
113
+ try:
114
+ c.callproc('DBMS_METADATA.SET_TRANSFORM_PARAM',(-1, 'TABLESPACE',False))
115
+ c.callproc("DBMS_METADATA.SET_TRANSFORM_PARAM",(-1,'STORAGE',False))
116
+ c.callproc("DBMS_METADATA.SET_TRANSFORM_PARAM",(-1,'SEGMENT_ATTRIBUTES',False))
117
+ c.callproc("DBMS_METADATA.SET_TRANSFORM_PARAM",(-1,'PRETTY',False))
118
+ except:
119
+ pass
120
+ ssql=db.res1("SELECT dbms_metadata.get_ddl(:otype,:oname) FROM DUAL",otype=otype,oname=oname).read()
121
+ return ssql
122
+
123
+ def readdata(arg):
124
+ global owner
125
+ dbdata["sql"]={}
126
+ dbdata["exp"]={}
127
+ if "owner" in arg:
128
+ owner=arg["owner"]
129
+ for i in vars(oracle):
130
+ if i.startswith("ana_"):
131
+ otype=i[4:]
132
+ dbdata["sql"][otype]={}
133
+ dbdata["exp"][otype]=[]
134
+ getattr(oracle,i)(otype)
135
+
136
+ def connect(arg):
137
+ global owner
138
+ if "dbcfg" in stdata:
139
+ db.conn=dbtt.dbc.connect()
140
+ if "owner" in stdata:
141
+ owner=stdata["owner"]
142
+ else:
143
+ owner=db.res1("select user from dual")
144
+
145
+ __all__=[]
@@ -25,6 +25,8 @@ class oracle(object):
25
25
  col["DATA_DEFAULT"]=col["DATA_DEFAULT"].strip()
26
26
  oridata.append(col)
27
27
  for column_name,data_type,char_length,data_precision,data_scale,nullable,default_length,data_default in db.exec("select column_name,data_type,char_length,data_precision,data_scale,nullable,default_length,data_default from all_tab_cols where owner='%s' and table_name='%s' order by column_id" %(owner,oname)):
28
+ if data_default:
29
+ data_default=data_default.strip()
28
30
  odata=odata+" %s%*s" %(column_name,maxcsize-len(column_name)+1," ")
29
31
  ctype="char"
30
32
  desc=db.res1("select comments from all_col_comments where table_name=:1 and column_name=:2 and owner=:3",[oname,column_name,owner])
@@ -83,7 +85,7 @@ class oracle(object):
83
85
  print("table %s column %s type %s length %s %s %s" %(oname,column_name,data_type,char_length,data_precision,data_scale))
84
86
  sys.exit(-1)
85
87
  if default_length:
86
- odata=odata+" default %s" %(data_default.strip())
88
+ odata=odata+" default %s" %(data_default)
87
89
  if nullable=="N":
88
90
  odata=odata+" not null"
89
91
  odata=odata+",\n"
@@ -2,8 +2,8 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys,importlib,os,shutil,dbcfg
5
- import database2text.tool as dbtt
6
- from database2text.tool import *
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
7
  import db2text as dt
8
8
 
9
9
  def 读文件():
@@ -12,8 +12,8 @@ def 读文件():
12
12
  if len(sys.argv)>1:
13
13
  fn=sys.argv[1]
14
14
  if not os.path.isfile(fn):
15
- print("can't open %s. you must create it or tell us another file name." %(fn))
16
- print("for help, you may need the file in %s" %(os.path.join(os.path.dirname(os.path.abspath(dbtt.__file__)),"datafile")))
15
+ print(f"无法打开文件{fn}. 你可以生成一个模块文件或者在命令行指定一个模板文件")
16
+ print("可以在目录%s下查看帮助和模板文件样例" %(os.path.join(os.path.dirname(os.path.abspath(dt.__file__)),"datafile")))
17
17
  sys.exit(-1)
18
18
  f=open(fn,"rb")
19
19
  if fn.endswith("md"):
@@ -43,12 +43,12 @@ def main():
43
43
  if section=="global":
44
44
  文件编码=stdata.get("code") or stdata.get("coding") or 文件编码
45
45
  if section in ["connect","global"] and "driver" in stdata:
46
- dbt=importlib.import_module('database2text.%s' %(stdata["driver"]))
46
+ dbt=importlib.import_module('db2text.db.%s' %(stdata["driver"]))
47
47
  if section == "connect" and "dbcfg" in stdata:
48
48
  dbtt.dbc=dbcfg.use(stdata["dbcfg"],ehm=2)
49
49
  dbtt.cfg=dbtt.dbc.cfg()
50
50
  if "driver" not in stdata:
51
- dbt=importlib.import_module('database2text.%s' %(驱动表.get(dbtt.cfg["db"],dbtt.cfg["db"])))
51
+ dbt=importlib.import_module('db2text.db.%s' %(驱动表.get(dbtt.cfg["db"],dbtt.cfg["db"])))
52
52
  if section!="global":
53
53
  if not dbt:
54
54
  print("需要在配置文件里设置driver")
@@ -118,7 +118,7 @@ class export(object):
118
118
 
119
119
  class dot(object):
120
120
  def __init__(self,arg):
121
- 模板文件=pathlib.Path.joinpath(pathlib.Path(__file__).parent,"datafile","dot.mb")
121
+ 模板文件=os.path.join(os.path.dirname(os.path.abspath(dt.__file__)),"datafile","dot.mb")
122
122
  模板=open(模板文件,encoding="utf8").read()
123
123
  分页数据=[]
124
124
  for page in arg.get("page","其它").split():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: db2text
3
- Version: 0.2.4
3
+ Version: 0.3.1
4
4
  Summary: database to text
5
5
  Home-page: https://gitee.com/chenc224/dbt
6
6
  Author: Chen chuan
@@ -0,0 +1,37 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ setup.py
5
+ db2text/__init__.py
6
+ db2text/data.py
7
+ db2text/dbt.py
8
+ db2text/tool.py
9
+ db2text/util.py
10
+ db2text.egg-info/PKG-INFO
11
+ db2text.egg-info/SOURCES.txt
12
+ db2text.egg-info/dependency_links.txt
13
+ db2text.egg-info/entry_points.txt
14
+ db2text.egg-info/not-zip-safe
15
+ db2text.egg-info/requires.txt
16
+ db2text.egg-info/top_level.txt
17
+ db2text/datafile/dbtmanual.md
18
+ db2text/datafile/dot.mb
19
+ db2text/datafile/sample/dbt_dot_mssql.txt
20
+ db2text/datafile/sample/dm/all.txt
21
+ db2text/datafile/sample/mysql/all.txt
22
+ db2text/datafile/sample/mysql/wiki.txt
23
+ db2text/datafile/sample/oceanbase/all.txt
24
+ db2text/datafile/sample/oceanbase/sjbf.txt
25
+ db2text/datafile/sample/opengauss/all.txt
26
+ db2text/datafile/sample/oracle/all.txt
27
+ db2text/datafile/sample/oracle/cc.txt
28
+ db2text/datafile/sample/oracle/crmrpt.txt
29
+ db2text/datafile/sample/oracle/sms.txt
30
+ db2text/datafile/sample/sqlserver/all.txt
31
+ db2text/db/__init__.py
32
+ db2text/db/dm.py
33
+ db2text/db/mssql.py
34
+ db2text/db/mysql.py
35
+ db2text/db/ob_oracle.py
36
+ db2text/db/opengauss.py
37
+ db2text/db/oracle11.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ db2text = db2text.dbt:main
3
+ dbt = db2text.dbt:main
@@ -0,0 +1 @@
1
+ db2text
@@ -8,7 +8,7 @@ with open("README.md", "r",encoding='utf-8') as fh:
8
8
 
9
9
  setuptools.setup(
10
10
  name="db2text",
11
- version="0.2.4",
11
+ version="0.3.1",
12
12
  author="Chen chuan",
13
13
  author_email="kcchen@139.com",
14
14
  description="database to text",
@@ -30,8 +30,8 @@ setuptools.setup(
30
30
  include_package_data = True,
31
31
  entry_points={
32
32
  'console_scripts': [
33
- 'dbt=database2text.dbt:main',
34
- 'db2text=database2text.dbt:main',
33
+ 'dbt=db2text.dbt:main',
34
+ 'db2text=db2text.dbt:main',
35
35
  ],
36
36
  },
37
37
  )
@@ -1 +0,0 @@
1
- print("util.init")
@@ -1,33 +0,0 @@
1
- LICENSE
2
- MANIFEST.in
3
- README.md
4
- setup.py
5
- database2text/__init__.py
6
- database2text/dbt.py
7
- database2text/dm.py
8
- database2text/mssql.py
9
- database2text/mysql.py
10
- database2text/opengauss.py
11
- database2text/oracle11.py
12
- database2text/tool.py
13
- database2text/datafile/dbtmanual.md
14
- database2text/datafile/dot.mb
15
- database2text/datafile/sample/dbt_dot_mssql.txt
16
- database2text/datafile/sample/dm/all.txt
17
- database2text/datafile/sample/mysql/all.txt
18
- database2text/datafile/sample/mysql/wiki.txt
19
- database2text/datafile/sample/opengauss/all.txt
20
- database2text/datafile/sample/oracle/all.txt
21
- database2text/datafile/sample/oracle/crmrpt.txt
22
- database2text/datafile/sample/sqlserver/all.txt
23
- db2text/__init__.py
24
- db2text/data.py
25
- db2text/util.py
26
- db2text.egg-info/PKG-INFO
27
- db2text.egg-info/SOURCES.txt
28
- db2text.egg-info/dependency_links.txt
29
- db2text.egg-info/entry_points.txt
30
- db2text.egg-info/not-zip-safe
31
- db2text.egg-info/requires.txt
32
- db2text.egg-info/top_level.txt
33
- db2text/db/__init__.py
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- db2text = database2text.dbt:main
3
- dbt = database2text.dbt:main
@@ -1,2 +0,0 @@
1
- database2text
2
- db2text
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes