db2text 0.3.1__tar.gz → 0.3.2__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 (41) hide show
  1. db2text-0.3.2/PKG-INFO +38 -0
  2. {db2text-0.3.1 → db2text-0.3.2}/db2text/data.py +5 -4
  3. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oceanbase/all.txt +2 -2
  4. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/dm.py +4 -4
  5. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/mssql.py +5 -3
  6. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/mysql.py +5 -2
  7. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/ob_oracle.py +3 -0
  8. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/opengauss.py +2 -2
  9. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/oracle11.py +5 -2
  10. {db2text-0.3.1 → db2text-0.3.2}/db2text/tool.py +3 -5
  11. {db2text-0.3.1 → db2text-0.3.2}/db2text/util.py +8 -2
  12. db2text-0.3.2/db2text.egg-info/PKG-INFO +38 -0
  13. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/entry_points.txt +1 -0
  14. {db2text-0.3.1 → db2text-0.3.2}/setup.py +1 -1
  15. db2text-0.3.1/PKG-INFO +0 -37
  16. db2text-0.3.1/db2text.egg-info/PKG-INFO +0 -37
  17. {db2text-0.3.1 → db2text-0.3.2}/LICENSE +0 -0
  18. {db2text-0.3.1 → db2text-0.3.2}/MANIFEST.in +0 -0
  19. {db2text-0.3.1 → db2text-0.3.2}/README.md +0 -0
  20. {db2text-0.3.1 → db2text-0.3.2}/db2text/__init__.py +0 -0
  21. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/dbtmanual.md +0 -0
  22. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/dot.mb +0 -0
  23. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/dbt_dot_mssql.txt +0 -0
  24. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/dm/all.txt +0 -0
  25. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/mysql/all.txt +0 -0
  26. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/mysql/wiki.txt +0 -0
  27. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oceanbase/sjbf.txt +0 -0
  28. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/opengauss/all.txt +0 -0
  29. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oracle/all.txt +0 -0
  30. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oracle/cc.txt +0 -0
  31. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oracle/crmrpt.txt +0 -0
  32. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/oracle/sms.txt +0 -0
  33. {db2text-0.3.1 → db2text-0.3.2}/db2text/datafile/sample/sqlserver/all.txt +0 -0
  34. {db2text-0.3.1 → db2text-0.3.2}/db2text/db/__init__.py +0 -0
  35. {db2text-0.3.1 → db2text-0.3.2}/db2text/dbt.py +0 -0
  36. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/SOURCES.txt +0 -0
  37. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/dependency_links.txt +0 -0
  38. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/not-zip-safe +0 -0
  39. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/requires.txt +0 -0
  40. {db2text-0.3.1 → db2text-0.3.2}/db2text.egg-info/top_level.txt +0 -0
  41. {db2text-0.3.1 → db2text-0.3.2}/setup.cfg +0 -0
db2text-0.3.2/PKG-INFO ADDED
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.1
2
+ Name: db2text
3
+ Version: 0.3.2
4
+ Summary: database to text
5
+ Home-page: https://gitee.com/chenc224/dbt
6
+ Author: Chen chuan
7
+ Author-email: kcchen@139.com
8
+ License: UNKNOWN
9
+ Description: # database to text
10
+
11
+ 数据库结构等导出到文本的工具。
12
+
13
+ 可以用来对数据库结构进行比较,检查变更,做版本控制等工作。
14
+
15
+ 也可以用来根据数据库结构自动生成文档,自动更新源代码等。
16
+
17
+ # 使用方法
18
+
19
+ ## 安装
20
+
21
+ 使用pip install db2text即可安装执行。注意这个工具在linux下开发调试,在windows使用如果有异常,请告知我。
22
+
23
+ ## 使用
24
+
25
+ 在命令行执行dbt即可。可以带参数指定命令文件,如果未指定,则使用当前目录下的dbt.txt文件。
26
+
27
+ 如果dbt跟系统内其它软件冲突,可以使用db2text,效果是相同的。
28
+
29
+ 详细的使用手册请参考
30
+
31
+ https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/dbtmanual.md
32
+
33
+ Platform: UNKNOWN
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Requires-Python: >=3.5
38
+ Description-Content-Type: text/markdown
@@ -4,10 +4,11 @@ __all__=["gd"]
4
4
 
5
5
  class gd(object): #全局数据
6
6
  #以下为设置项
7
- coding="utf8" #字符集,默认为utf8
8
- linebreak="\n" #检测到换行符,则替换掉这个,没检测到,使用这个默认的
9
- infolevel=1 #设置提示信息级别
10
- localinfolevel=1 #局部消息级别
7
+ coding="utf8" #字符集,默认为utf8
8
+ linebreak="\n" #检测到换行符,则替换掉这个,没检测到,使用这个默认的
9
+ infolevel=1 #设置提示信息级别
10
+ localinfolevel=1 #局部消息级别
11
+ replacelinebreak=":" #替换注释里的回车、回车换行和换行
11
12
 
12
13
  #以下为数据项
13
14
  oritext=[] #保存文本的初始值
@@ -6,7 +6,7 @@
6
6
  #执行时扫描配置文件,把每一段的内容传递给相应的处理函数处理
7
7
  :connect
8
8
 
9
- dbcfg=jyzt
9
+ dbcfg=sms2
10
10
 
11
11
  :readdata
12
12
 
@@ -30,7 +30,7 @@ end=
30
30
  #根据模板生成dot文件,调用neato生成pdf文件
31
31
  :dot
32
32
  #cmd=neato -Tpdf test/oracle/all.dot -o local/oracle/alldot.pdf
33
- dotdir=local/oceanbase
33
+ dotdir=test/oceanbase
34
34
  pdfdir=local/oceanbase
35
35
  filename=all
36
36
  dotcmd=neato
@@ -2,8 +2,8 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys,cx_Oracle,json
5
- import database2text.tool as dbtt
6
- from database2text.tool import *
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
7
 
8
8
  class dm(object):
9
9
  def ana_TABLE(otype):
@@ -17,7 +17,7 @@ class dm(object):
17
17
  md=[] #markdown等用的字段数据,每字段一个字典,包括 "name": 字段名,"desc": 注释,"type": 数据类型,"size":字段长度,"null":True of False,是否可为空,"default":默认值
18
18
  maxcsize=db.res1("select max(length(column_name)) from all_tab_cols where owner='%s' and table_name='%s'" %(owner,oname))
19
19
  tdesc=db.res1("select comments from all_tab_comments where owner=:1 and table_name=:2",[owner,oname])
20
- if not tdesc:tdesc=""
20
+ tdesc=dt.replacelinebreak(tdesc)
21
21
  oridata=[]
22
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
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])
@@ -28,7 +28,7 @@ class dm(object):
28
28
  odata=odata+" %s%*s" %(column_name,maxcsize-len(column_name)+1," ")
29
29
  ctype="char"
30
30
  desc=db.res1("select comments from all_col_comments where table_name=:1 and column_name=:2 and owner=:3",[oname,column_name,owner])
31
- if not desc:desc=""
31
+ desc=dt.replacelinebreak(desc)
32
32
  if data_type in ("NUMBER","NUMERIC"):
33
33
  if data_precision is not None and data_scale is not None:
34
34
  if data_scale==0:
@@ -2,8 +2,9 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys
5
- import database2text.tool as dbtt
6
- from database2text.tool import *
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
+ import db2text as dt
7
8
 
8
9
  __all__=["connect","readdata"]
9
10
 
@@ -24,6 +25,7 @@ class mssql(object):
24
25
  print(f"{catalog}.{schema}.{表名} 找不到表id")
25
26
  continue
26
27
  表注释=db.res1(f"select value from sys.extended_properties where major_id={表id} and class=1 and name='MS_Description'") or ""
28
+ 表注释=dt.replacelinebreak(表注释)
27
29
  主键名=db.res1(f"SELECT k.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS c JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS k ON c.CONSTRAINT_TYPE = 'PRIMARY KEY' AND c.CONSTRAINT_NAME = k.CONSTRAINT_NAME WHERE c.TABLE_NAME = '{表名}'")
28
30
  主键列=[]
29
31
  if 主键名:
@@ -34,6 +36,7 @@ class mssql(object):
34
36
  for i in db.exec2(f"select * from sys.columns where object_id={表id} order by column_id"):
35
37
  原始信息.append(i)
36
38
  字段描述=db.res1(f"select value from sys.extended_properties where major_id={i['object_id']} and minor_id={i['column_id']}")
39
+ 字段描述=dt.replacelinebreak(字段描述 or "")
37
40
  字段类型=db.res1(f"select name from sys.types where system_type_id={i['system_type_id']} and user_type_id={i['user_type_id']}")
38
41
  if i["precision"]==0: #字符型
39
42
  ts=f"{字段类型}({i['max_length']})"
@@ -67,4 +70,3 @@ def connect(arg):
67
70
  return db.conn
68
71
  else:
69
72
  return dbtt.connect(arg,"pytds")
70
-
@@ -2,8 +2,9 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys,pymysql,dbcfg
5
- import database2text.tool as dbtt
6
- from database2text.tool import *
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
+ import db2text as dt
7
8
 
8
9
  class mysql(object):
9
10
  def ana_TABLE(otype):
@@ -15,6 +16,7 @@ class mysql(object):
15
16
  oridata=[]
16
17
  coldata=[]
17
18
  tdesc=db.res1("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME ='%s' AND TABLE_SCHEMA = '%s'" %(oname,database))
19
+ tdesc=dt.replacelinebreak(tdesc)
18
20
  主键列=[]
19
21
  for pkcol, in db.exec(f"select column_name from information_schema.key_column_usage where TABLE_SCHEMA='{database}' and table_name='{oname}' and constraint_name='PRIMARY'"):
20
22
  主键列.append(pkcol)
@@ -33,6 +35,7 @@ class mysql(object):
33
35
  oridata=[]
34
36
  coldata=[]
35
37
  tdesc=db.res1("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME ='%s' AND TABLE_SCHEMA = '%s'" %(oname,database))
38
+ tdesc=dt.replacelinebreak(tdesc)
36
39
  md=[] #markdown等用的字段数据,每字段一个字典
37
40
  for i in db.exec2(f"select * from information_schema.COLUMNS where TABLE_SCHEMA='{database}' and table_name='{oname}' order by ORDINAL_POSITION"):
38
41
  oridata.append(i)
@@ -4,6 +4,7 @@
4
4
  import sys,json
5
5
  import db2text.tool as dbtt
6
6
  from db2text.tool import *
7
+ import db2text as dt
7
8
 
8
9
  class oracle(object):
9
10
  def ana_TABLE(otype):
@@ -18,6 +19,7 @@ class oracle(object):
18
19
  maxcsize=db.res1("select max(length(column_name)) from all_tab_cols where owner='%s' and table_name='%s'" %(owner,oname))
19
20
  tdesc=db.res1("select comments from all_tab_comments where owner=:1 and table_name=:2",[owner,oname])
20
21
  if not tdesc:tdesc=""
22
+ tdesc=dt.replacelinebreak(tdesc)
21
23
  oridata=[]
22
24
  for col in db.exec2("select * from all_tab_cols where owner='%s' and table_name='%s' order by column_id" %(owner,oname)):
23
25
  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])
@@ -31,6 +33,7 @@ class oracle(object):
31
33
  ctype="char"
32
34
  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
35
  if not desc:desc=""
36
+ desc=dt.replacelinebreak(desc)
34
37
  if data_type=="NUMBER":
35
38
  if data_precision is not None and data_scale is not None:
36
39
  if data_scale==0:
@@ -2,8 +2,8 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys,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
 
8
8
  字段类型={}
9
9
 
@@ -2,8 +2,9 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import sys,cx_Oracle,json
5
- import database2text.tool as dbtt
6
- from database2text.tool import *
5
+ import db2text.tool as dbtt
6
+ from db2text.tool import *
7
+ import db2text as dt
7
8
 
8
9
  class oracle(object):
9
10
  def ana_TABLE(otype):
@@ -18,6 +19,7 @@ class oracle(object):
18
19
  maxcsize=db.res1("select max(length(column_name)) from all_tab_cols where owner='%s' and table_name='%s'" %(owner,oname))
19
20
  tdesc=db.res1("select comments from all_tab_comments where owner=:1 and table_name=:2",[owner,oname])
20
21
  if not tdesc:tdesc=""
22
+ tdesc=dt.replacelinebreak(tdesc)
21
23
  oridata=[]
22
24
  for col in db.exec2("select * from all_tab_cols where owner='%s' and table_name='%s' order by column_id" %(owner,oname)):
23
25
  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])
@@ -31,6 +33,7 @@ class oracle(object):
31
33
  ctype="char"
32
34
  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
35
  if not desc:desc=""
36
+ desc=dt.replacelinebreak(desc)
34
37
  if data_type=="NUMBER":
35
38
  if data_precision is not None and data_scale is not None:
36
39
  if data_scale==0:
@@ -5,7 +5,7 @@ import sys,os,difflib,jinja2,re,json,datetime,importlib,pathlib
5
5
  import db2text as dt
6
6
  from pprint import pprint
7
7
 
8
- __all__=["db","ckd","dbdata","storidata","stdata","检查匹配","cpt"]
8
+ __all__=["db","ckd","dbdata","storidata","stdata","检查匹配"]
9
9
 
10
10
  def mkdir(dirname):
11
11
  if not os.path.isdir(dirname):
@@ -15,10 +15,6 @@ def quit(errinfo,exitcode=0):
15
15
  print(errinfo)
16
16
  sys.exit(exitcode)
17
17
 
18
- def cpt(t):
19
- import json
20
- print(json.dumps(t,ensure_ascii=False,skipkeys=False,indent=2))
21
-
22
18
  class ComplexEncoder(json.JSONEncoder):
23
19
  def default(self, obj):
24
20
  if isinstance(obj, datetime.datetime):
@@ -163,6 +159,8 @@ class dot(object):
163
159
  pdfname=os.path.join(arg.get("pdfdir","."),f"{arg['filename']}.pdf")
164
160
  with open(pdfname,"wb") as fout:
165
161
  pdfout.write(fout)
162
+ for i in pdf列表:
163
+ os.unlink(i)
166
164
 
167
165
  class render(object):
168
166
  def __init__(self,arg):
@@ -1,7 +1,7 @@
1
- __all__=["inittext","p","capture","mergecolumndata","createcolumndata","replacenewdata","analydata","printdiff"]
1
+ __all__=["inittext","p","capture","mergecolumndata","createcolumndata","replacenewdata","analydata","printdiff","replacelinebreak"]
2
2
 
3
3
  import db2text as dt
4
- import time,copy,difflib
4
+ import time,copy,difflib,re
5
5
  from pprint import pprint
6
6
 
7
7
  def inittext(text):
@@ -111,3 +111,9 @@ def printdiff(t1,t2):
111
111
  '显示t1和t2这两个列表之间的文本差异'
112
112
  diff=difflib.Differ()
113
113
  print("\n".join(difflib.context_diff(t1,t2)))
114
+
115
+ def replacelinebreak(t):
116
+ '替换回车、回车换行、换行为dt.gd.replacelinebreak'
117
+ if not t: #如果t为空,返回空串
118
+ return ""
119
+ return re.sub(r"\r\n|\r|\n", dt.gd.replacelinebreak, t)
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.1
2
+ Name: db2text
3
+ Version: 0.3.2
4
+ Summary: database to text
5
+ Home-page: https://gitee.com/chenc224/dbt
6
+ Author: Chen chuan
7
+ Author-email: kcchen@139.com
8
+ License: UNKNOWN
9
+ Description: # database to text
10
+
11
+ 数据库结构等导出到文本的工具。
12
+
13
+ 可以用来对数据库结构进行比较,检查变更,做版本控制等工作。
14
+
15
+ 也可以用来根据数据库结构自动生成文档,自动更新源代码等。
16
+
17
+ # 使用方法
18
+
19
+ ## 安装
20
+
21
+ 使用pip install db2text即可安装执行。注意这个工具在linux下开发调试,在windows使用如果有异常,请告知我。
22
+
23
+ ## 使用
24
+
25
+ 在命令行执行dbt即可。可以带参数指定命令文件,如果未指定,则使用当前目录下的dbt.txt文件。
26
+
27
+ 如果dbt跟系统内其它软件冲突,可以使用db2text,效果是相同的。
28
+
29
+ 详细的使用手册请参考
30
+
31
+ https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/dbtmanual.md
32
+
33
+ Platform: UNKNOWN
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Requires-Python: >=3.5
38
+ Description-Content-Type: text/markdown
@@ -1,3 +1,4 @@
1
1
  [console_scripts]
2
2
  db2text = db2text.dbt:main
3
3
  dbt = db2text.dbt:main
4
+
@@ -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.3.1",
11
+ version="0.3.2",
12
12
  author="Chen chuan",
13
13
  author_email="kcchen@139.com",
14
14
  description="database to text",
db2text-0.3.1/PKG-INFO DELETED
@@ -1,37 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: db2text
3
- Version: 0.3.1
4
- Summary: database to text
5
- Home-page: https://gitee.com/chenc224/dbt
6
- Author: Chen chuan
7
- Author-email: kcchen@139.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.5
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
-
15
- # database to text
16
-
17
- 数据库结构等导出到文本的工具。
18
-
19
- 可以用来对数据库结构进行比较,检查变更,做版本控制等工作。
20
-
21
- 也可以用来根据数据库结构自动生成文档,自动更新源代码等。
22
-
23
- # 使用方法
24
-
25
- ## 安装
26
-
27
- 使用pip install db2text即可安装执行。注意这个工具在linux下开发调试,在windows使用如果有异常,请告知我。
28
-
29
- ## 使用
30
-
31
- 在命令行执行dbt即可。可以带参数指定命令文件,如果未指定,则使用当前目录下的dbt.txt文件。
32
-
33
- 如果dbt跟系统内其它软件冲突,可以使用db2text,效果是相同的。
34
-
35
- 详细的使用手册请参考
36
-
37
- https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/dbtmanual.md
@@ -1,37 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: db2text
3
- Version: 0.3.1
4
- Summary: database to text
5
- Home-page: https://gitee.com/chenc224/dbt
6
- Author: Chen chuan
7
- Author-email: kcchen@139.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.5
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
-
15
- # database to text
16
-
17
- 数据库结构等导出到文本的工具。
18
-
19
- 可以用来对数据库结构进行比较,检查变更,做版本控制等工作。
20
-
21
- 也可以用来根据数据库结构自动生成文档,自动更新源代码等。
22
-
23
- # 使用方法
24
-
25
- ## 安装
26
-
27
- 使用pip install db2text即可安装执行。注意这个工具在linux下开发调试,在windows使用如果有异常,请告知我。
28
-
29
- ## 使用
30
-
31
- 在命令行执行dbt即可。可以带参数指定命令文件,如果未指定,则使用当前目录下的dbt.txt文件。
32
-
33
- 如果dbt跟系统内其它软件冲突,可以使用db2text,效果是相同的。
34
-
35
- 详细的使用手册请参考
36
-
37
- https://gitee.com/chenc224/dbt/blob/master/database2text/datafile/dbtmanual.md
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes