buildz 0.5.9__tar.gz → 0.6.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.
- {buildz-0.5.9/buildz.egg-info → buildz-0.6.1}/PKG-INFO +4 -2
- {buildz-0.5.9 → buildz-0.6.1}/README.md +2 -0
- buildz-0.6.1/buildz/db/__main__.py +3 -0
- buildz-0.6.1/buildz/db/dv/basez.py +80 -0
- buildz-0.6.1/buildz/db/dv/clickhousez.py +34 -0
- buildz-0.6.1/buildz/db/dv/lib/readme +10 -0
- buildz-0.6.1/buildz/db/dv/mysqlz.py +38 -0
- buildz-0.6.1/buildz/db/dv/oraclez.py +59 -0
- buildz-0.6.1/buildz/db/dv/structz.py +207 -0
- buildz-0.6.1/buildz/db/install.txt +4 -0
- buildz-0.6.1/buildz/db/run.conf +10 -0
- buildz-0.6.1/buildz/db/runz.py +103 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/help/search.js +6 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/search/deal.py +5 -1
- {buildz-0.5.9 → buildz-0.6.1}/buildz/fz/fio.py +11 -0
- buildz-0.6.1/buildz/fz/lsf.py +192 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc/confs.py +2 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/call.py +12 -2
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/mcall.py +16 -4
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/obj.py +27 -8
- {buildz-0.5.9 → buildz-0.6.1}/buildz/pyz.py +5 -1
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/__init__.py +6 -1
- buildz-0.6.1/buildz/xf/code.py +60 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/listz.py +3 -5
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/lr.py +15 -4
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/lrval.py +5 -5
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/mapz.py +3 -5
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/nextz.py +1 -6
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/reval.py +1 -1
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/spt.py +1 -1
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/strz.py +140 -51
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/mg.py +3 -3
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/test.py +29 -6
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/mapz.py +6 -1
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/readz.py +10 -10
- {buildz-0.5.9 → buildz-0.6.1/buildz.egg-info}/PKG-INFO +4 -2
- {buildz-0.5.9 → buildz-0.6.1}/buildz.egg-info/SOURCES.txt +11 -0
- {buildz-0.5.9 → buildz-0.6.1}/setup.py +2 -2
- buildz-0.5.9/buildz/fz/lsf.py +0 -113
- {buildz-0.5.9 → buildz-0.6.1}/LICENSE +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/MANIFEST.in +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/__main__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/argx.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/cmd.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/ioc/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/ioc/help.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/myers/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/myers/help.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/conf/ioc.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/conf/main.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/conf/myers.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/conf/search.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/conf/xf.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/help/default.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/help/ioc.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/help/myers.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/help/xf.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/res/test.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/search/help.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/test.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/xf/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/demo/xf/help.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/fz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/fz/dirz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/fz/fhs.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/init.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc/conf.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc/single.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/calls.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/call_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/call_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/calls_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/calls_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/deal_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/deals.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/env_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/ioc_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/iocf_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/join_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/list_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/map_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/mcall_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/mcall_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/obj_cst_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/obj_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/obj_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/obj_set_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/ovar_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/ref_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/var_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/xfile_defaults.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/conf/xfile_lists.js +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/deal.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/demo.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/env.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/ioc.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/iocf.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/join.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/list.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/map.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/ovar.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/ref.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/val.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/var.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/ioc/ioc_deal/xfile.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/tz/__init__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/tz/myers_diff.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/__main__.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/file.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/buffer.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/listz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/lr.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/lrval.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/nextz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/reval.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/setz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/spc.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/spt.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/deal/strz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/exp.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/item.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/mg.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loader/pos.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/buffer.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/setz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/deal/spc.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/exp.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/item.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/pos.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/loaderz/test1.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/read.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/stack.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/write.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/base.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/conf.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/deal/jsonval.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/deal/listz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/deal/mapz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/deal/reval.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/deal/strz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/itemz.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/writer/mg.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz/xf/xargs.py +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz.egg-info/dependency_links.txt +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/buildz.egg-info/top_level.txt +0 -0
- {buildz-0.5.9 → buildz-0.6.1}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: buildz
|
3
|
-
Version: 0.
|
4
|
-
Summary: 配置读写(基于json
|
3
|
+
Version: 0.6.1
|
4
|
+
Summary: 配置读写(基于json格式进行简化)、ioc、以及其他工具代码。a json-base file format's read and write code by python, and codes to read and product object from configure file in such format(ioc), and other tool codes
|
5
5
|
Home-page: https://github.com/buildCodeZ/buildz
|
6
6
|
Author: Zzz
|
7
7
|
Author-email: 1309458652@qq.com
|
@@ -21,9 +21,11 @@ License-File: LICENSE
|
|
21
21
|
buildz.argx: 按格式读命令行参数
|
22
22
|
buildz.tz: 加些工具,目前只有myerse diff字符串比较算法
|
23
23
|
buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
|
24
|
+
buildz.db: sql集成工具,自用,里面import了其他sql库,使用运行"python -m buildz.db 配置文件路径"
|
24
25
|
代码关系:
|
25
26
|
buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz都是独立的模块
|
26
27
|
buildz.ioc需要buildz.xf和buildz.pyz
|
28
|
+
buildz.db需要buildz.xf
|
27
29
|
buildz.demo需要其他全部模块
|
28
30
|
|
29
31
|
运行python -m buildz查看帮助
|
@@ -8,9 +8,11 @@
|
|
8
8
|
buildz.argx: 按格式读命令行参数
|
9
9
|
buildz.tz: 加些工具,目前只有myerse diff字符串比较算法
|
10
10
|
buildz.demo: 使用参考,运行"python -m buildz"会用这个模块
|
11
|
+
buildz.db: sql集成工具,自用,里面import了其他sql库,使用运行"python -m buildz.db 配置文件路径"
|
11
12
|
代码关系:
|
12
13
|
buildz.xf, buildz.pyz, buildz.argx, buildz.fz, buildz.tz都是独立的模块
|
13
14
|
buildz.ioc需要buildz.xf和buildz.pyz
|
15
|
+
buildz.db需要buildz.xf
|
14
16
|
buildz.demo需要其他全部模块
|
15
17
|
|
16
18
|
运行python -m buildz查看帮助
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import sys
|
2
|
+
from .structz import ItDv
|
3
|
+
def sp(obj):
|
4
|
+
return super(obj.__class__, obj)
|
5
|
+
|
6
|
+
pass
|
7
|
+
class SimpleDv(ItDv):
|
8
|
+
# func to impl:
|
9
|
+
def to_list(self, query_result):
|
10
|
+
return []
|
11
|
+
def sql_tables(self):
|
12
|
+
return "select TABLE_NAME tableName,TABLE_COMMENT comemnt,TABLE_ROWS dataNums from information_schema.tables where table_schema='"+self.db+"'"
|
13
|
+
def new_con(self):
|
14
|
+
return None
|
15
|
+
def new_cursor(self):
|
16
|
+
return None
|
17
|
+
def init(self, *argv, **maps):
|
18
|
+
pass
|
19
|
+
# func already impl
|
20
|
+
def check_query(self, s):
|
21
|
+
arr = s.split(" ")
|
22
|
+
k = arr[0].strip().lower()
|
23
|
+
rst = k not in "delete,insert,update,create,drop,commit".split(",")
|
24
|
+
return rst
|
25
|
+
def __init__(self, host, port, user, pwd, db, *argv, **maps):
|
26
|
+
self.host = host
|
27
|
+
self.port = port
|
28
|
+
self.user = user
|
29
|
+
self.pwd = pwd
|
30
|
+
self.db = db
|
31
|
+
self.con = None
|
32
|
+
self.cursor = None
|
33
|
+
self.init(*argv, **maps)
|
34
|
+
def begin(self):
|
35
|
+
self.con = self.new_con()
|
36
|
+
self.cursor = self.new_cursor()
|
37
|
+
def close(self):
|
38
|
+
self.cursor.close()
|
39
|
+
self.con.close()
|
40
|
+
self.cursor = None
|
41
|
+
self.con = None
|
42
|
+
def is_open(self):
|
43
|
+
return self.cursor is not None
|
44
|
+
def commit(self):
|
45
|
+
self.cursor.close()
|
46
|
+
self.con.commit()
|
47
|
+
self.cursor = self.new_cursor()
|
48
|
+
def refresh(self):
|
49
|
+
self.cursor.close()
|
50
|
+
self.cursor = self.new_cursor()
|
51
|
+
def query(self, sql, vals=()):
|
52
|
+
# return list, first row is key
|
53
|
+
tmp = self.cursor.execute(sql, vals)
|
54
|
+
print("[TESTZ] exe:",tmp)
|
55
|
+
rst = self.cursor.fetchall()
|
56
|
+
return self.to_list(rst)
|
57
|
+
def execute(self, sql, vals=()):
|
58
|
+
tmp = self.cursor.execute(sql, vals)
|
59
|
+
return tmp
|
60
|
+
|
61
|
+
pass
|
62
|
+
|
63
|
+
# user|pwd@host:port/db
|
64
|
+
def fetch(args):
|
65
|
+
if type(args) == str:
|
66
|
+
args = args.split(" ")
|
67
|
+
url = args[0].strip()
|
68
|
+
url, db = url.split("/")
|
69
|
+
tmp = url.split(":")
|
70
|
+
if len(tmp)==2:
|
71
|
+
host, port = tmp
|
72
|
+
port = int(port)
|
73
|
+
else:
|
74
|
+
host = tmp[0]
|
75
|
+
port = None
|
76
|
+
user = args[1].strip()
|
77
|
+
pwd = args[2].strip()
|
78
|
+
return host, port, user, pwd, db
|
79
|
+
|
80
|
+
pass
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
try:
|
3
|
+
import clickhouse_driver
|
4
|
+
except ModuleNotFoundError:
|
5
|
+
raise Exception("module not found, try: pip install clickhouse-driver")
|
6
|
+
from clickhouse_driver import connect
|
7
|
+
from clickhouse_driver import Client
|
8
|
+
import sys
|
9
|
+
from .basez import SimpleDv, fetch
|
10
|
+
from .structz import CMD
|
11
|
+
class Db(SimpleDv):
|
12
|
+
# func to impl:
|
13
|
+
def to_list(self, rst):
|
14
|
+
rows = self.cursor.description
|
15
|
+
keys = [k[0].lower() for k in rows]
|
16
|
+
result = []
|
17
|
+
result.append(keys)
|
18
|
+
if rst is None or len(rst)==0:
|
19
|
+
return result
|
20
|
+
result += rst
|
21
|
+
return result
|
22
|
+
def new_con(self):
|
23
|
+
return connect('clickhouse://{user}:{pwd}@{host}:{port}/{db}'.format(user = self.user, db = self.db, pwd =self.pwd, host = self.host, port = self.port))
|
24
|
+
def new_cursor(self):
|
25
|
+
return self.con.cursor()
|
26
|
+
def init(self, *argv, **maps):
|
27
|
+
pass
|
28
|
+
|
29
|
+
pass
|
30
|
+
def build(argv, conf):
|
31
|
+
dv = Db(*fetch(argv))
|
32
|
+
return CMD(dv)
|
33
|
+
|
34
|
+
pass
|
@@ -0,0 +1,38 @@
|
|
1
|
+
try:
|
2
|
+
import pymysql
|
3
|
+
except ModuleNotFoundError:
|
4
|
+
raise Exception("module not found, try: pip install pymysql")
|
5
|
+
import sys
|
6
|
+
from .basez import SimpleDv, fetch
|
7
|
+
from .structz import CMD
|
8
|
+
class Db(SimpleDv):
|
9
|
+
# func to impl:
|
10
|
+
def to_list(self, rst):
|
11
|
+
result = []
|
12
|
+
if rst is None or len(rst)==0:
|
13
|
+
return result
|
14
|
+
a = rst[0]
|
15
|
+
keys = list(a.keys())
|
16
|
+
result.append(keys)
|
17
|
+
for obj in rst:
|
18
|
+
v = [obj[k] for k in keys]
|
19
|
+
result.append(v)
|
20
|
+
return result
|
21
|
+
def new_con(self):
|
22
|
+
return pymysql.connect(host=self.host,
|
23
|
+
port = self.port, user =self.user,
|
24
|
+
password =self.pwd, database = self.db,
|
25
|
+
charset='utf8',init_command="SET SESSION time_zone='+08:00'")
|
26
|
+
def new_cursor(self):
|
27
|
+
return self.con.cursor(pymysql.cursors.DictCursor)
|
28
|
+
def init(self, *argv, **maps):
|
29
|
+
if self.port is None:
|
30
|
+
self.port = 3306
|
31
|
+
pass
|
32
|
+
|
33
|
+
pass
|
34
|
+
def build(argv, conf):
|
35
|
+
dv = Db(*fetch(argv))
|
36
|
+
return CMD(dv)
|
37
|
+
|
38
|
+
pass
|
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
dp = os.path.dirname(__file__)
|
5
|
+
gdp = os.path.join(dp, "lib")
|
6
|
+
|
7
|
+
def init_path(dp):
|
8
|
+
path = os.environ["PATH"]
|
9
|
+
if sys.platform.lower().find("win")>=0:
|
10
|
+
cb = ";"
|
11
|
+
else:
|
12
|
+
cb = ":"
|
13
|
+
path = path +cb+dp
|
14
|
+
os.environ["PATH"] = path
|
15
|
+
|
16
|
+
pass
|
17
|
+
|
18
|
+
#init_path(dp)
|
19
|
+
import sys
|
20
|
+
from .basez import SimpleDv, fetch
|
21
|
+
from .structz import CMD
|
22
|
+
class Db(SimpleDv):
|
23
|
+
# func to impl:
|
24
|
+
def to_list(self, rst):
|
25
|
+
rows = self.cursor.description
|
26
|
+
keys = [k[0].lower() for k in rows]
|
27
|
+
result = []
|
28
|
+
result.append(keys)
|
29
|
+
if rst is None or len(rst)==0:
|
30
|
+
return result
|
31
|
+
result += rst
|
32
|
+
return result
|
33
|
+
def new_con(self):
|
34
|
+
if self.port is not None:
|
35
|
+
add = ":"+str(self.port)
|
36
|
+
else:
|
37
|
+
add = ""
|
38
|
+
try:
|
39
|
+
import cx_Oracle as pymysql
|
40
|
+
except ModuleNotFoundError:
|
41
|
+
raise Exception("module not found, try: pip install cx-Oracle")
|
42
|
+
return pymysql.connect(self.user, self.pwd, self.host+add+"/"+self.db)
|
43
|
+
def new_cursor(self):
|
44
|
+
return self.con.cursor()
|
45
|
+
def init(self, *argv, **maps):
|
46
|
+
pass
|
47
|
+
|
48
|
+
pass
|
49
|
+
def build(argv, conf):
|
50
|
+
k = 'oracle_lib'
|
51
|
+
dp = gdp
|
52
|
+
if k in conf:
|
53
|
+
dp = conf[k]
|
54
|
+
init_path(dp)
|
55
|
+
#print(f"oracle lib: {dp}")
|
56
|
+
dv = Db(*fetch(argv))
|
57
|
+
return CMD(dv)
|
58
|
+
|
59
|
+
pass
|
@@ -0,0 +1,207 @@
|
|
1
|
+
#import pymysql
|
2
|
+
import sys
|
3
|
+
class ItDv:
|
4
|
+
def begin(self):
|
5
|
+
pass
|
6
|
+
def close(self):
|
7
|
+
pass
|
8
|
+
def is_open(self):
|
9
|
+
return False
|
10
|
+
def commit(self):
|
11
|
+
pass
|
12
|
+
def refresh(self):
|
13
|
+
pass
|
14
|
+
def check_query(self, s):
|
15
|
+
return False
|
16
|
+
def query(self, sql, vals=()):
|
17
|
+
# return list, first row is key
|
18
|
+
return []
|
19
|
+
def execute(self, sql, vals=()):
|
20
|
+
return None
|
21
|
+
def sql_tables(self):
|
22
|
+
return ""
|
23
|
+
|
24
|
+
pass
|
25
|
+
|
26
|
+
class CMD:
|
27
|
+
def begin(self):
|
28
|
+
return self.dv.begin()
|
29
|
+
def close(self):
|
30
|
+
return self.dv.close()
|
31
|
+
def __init__(self, dv, simple_format = True):
|
32
|
+
self.s_rst = ""
|
33
|
+
self.dv = dv
|
34
|
+
self.simple_format = simple_format
|
35
|
+
def __enter__(self, *argv, **maps):
|
36
|
+
self.dv.begin()
|
37
|
+
return self
|
38
|
+
def __exit__(self, *argv, **maps):
|
39
|
+
self.dv.close()
|
40
|
+
def exec(self, fc, sql, vals = ()):
|
41
|
+
need_close = False
|
42
|
+
if not self.dv.is_open():
|
43
|
+
self.dv.begin()
|
44
|
+
need_close = True
|
45
|
+
rst = fc(sql, vals)
|
46
|
+
if need_close:
|
47
|
+
self.dv.close()
|
48
|
+
return rst
|
49
|
+
def query(self, sql, vals = ()):
|
50
|
+
return self.exec(self.dv.query, sql, vals)
|
51
|
+
def execute(self, sql, vals = ()):
|
52
|
+
return self.exec(self.dv.execute, sql, vals)
|
53
|
+
def s_print(self, *args):
|
54
|
+
args = [str(k) for k in args]
|
55
|
+
s = " ".join(args)
|
56
|
+
s = s+"\n"
|
57
|
+
self.s_rst += s
|
58
|
+
def s_flush(self):
|
59
|
+
out = self.s_rst
|
60
|
+
self.s_rst = ""
|
61
|
+
return out
|
62
|
+
def rp(self, s):
|
63
|
+
return s
|
64
|
+
rps = ["\n\\n","\r\\r","\t\\t"]
|
65
|
+
for rp in rps:
|
66
|
+
s = s.replace(rp[0], rp[1:])
|
67
|
+
return s
|
68
|
+
def sz(self, s):
|
69
|
+
try:
|
70
|
+
s = s.encode("gbk")
|
71
|
+
except Exception as exp:
|
72
|
+
print("SZ exp:", exp)
|
73
|
+
return min(100, len(s))
|
74
|
+
def jstr(self, obj):
|
75
|
+
import datetime
|
76
|
+
import decimal
|
77
|
+
if type(obj) == datetime.datetime:
|
78
|
+
obj = str(obj)
|
79
|
+
if type(obj) == decimal.Decimal:
|
80
|
+
obj = str(obj)
|
81
|
+
if type(obj) == bytes:
|
82
|
+
obj = list(obj)[0]
|
83
|
+
import json
|
84
|
+
rs = json.dumps(obj, ensure_ascii=0)
|
85
|
+
return rs
|
86
|
+
def tr_sz(self, s, sz):
|
87
|
+
try:
|
88
|
+
s = s.encode("gbk")
|
89
|
+
s = s+(b" "*(sz-len(s)))
|
90
|
+
s = s.decode("gbk")
|
91
|
+
except Exception as exp:
|
92
|
+
print("TR_SZ exp:", exp)
|
93
|
+
return s
|
94
|
+
def format(self, arr):
|
95
|
+
arr = [[self.rp(k) for k in obj] for obj in arr]
|
96
|
+
if self.simple_format and len(arr)>0:
|
97
|
+
sz = [[self.sz(k) for k in obj] for obj in arr]
|
98
|
+
l = len(arr[0])
|
99
|
+
szs = [max([obj[i] for obj in sz]) for i in range(l)]
|
100
|
+
arr = [[self.tr_sz(obj[i], szs[i]) for i in range(l)] for obj in arr]
|
101
|
+
arr = [" | ".join(k) for k in arr]
|
102
|
+
arr = ["[[ "+k+" ]]" for k in arr]
|
103
|
+
return "\n".join(arr)
|
104
|
+
def single(self, s):
|
105
|
+
s=s.strip()
|
106
|
+
if s == "commits":
|
107
|
+
self.dv.commit()
|
108
|
+
elif s == "reset":
|
109
|
+
self.dv.close()
|
110
|
+
self.dv.begin()
|
111
|
+
elif s == "refresh":
|
112
|
+
self.dv.refresh()
|
113
|
+
elif s == "table":
|
114
|
+
s = self.dv.sql_tables()
|
115
|
+
self.s_print(self.single(s))
|
116
|
+
elif s == "exit":
|
117
|
+
raise Exception("exit")
|
118
|
+
elif s.split(" ")[0] == "source":
|
119
|
+
# source filepath [encoding]
|
120
|
+
arr = s.split(" ")
|
121
|
+
fp =arr[1].strip()
|
122
|
+
cd = "utf-8"
|
123
|
+
if len(arr)>2:
|
124
|
+
cd = arr[2].strip().lower()
|
125
|
+
with open(fp, 'rb') as f:
|
126
|
+
s = f.read().decode(cd)
|
127
|
+
arr = s.split(";")
|
128
|
+
for sql in arr:
|
129
|
+
if sql.strip() == "":
|
130
|
+
continue
|
131
|
+
_sql = sql+";"
|
132
|
+
self.s_print("sql:", _sql)
|
133
|
+
tmp = self.execute(_sql)
|
134
|
+
self.s_print(tmp)
|
135
|
+
self.s_print("done source", fp)
|
136
|
+
elif s.split(" ")[0] == "export":
|
137
|
+
# export filepath encoding sql;
|
138
|
+
self.s_print("export:", s)
|
139
|
+
arr = s.split(" ")
|
140
|
+
fp =arr[1].strip()
|
141
|
+
cd = arr[2].strip().lower()
|
142
|
+
s = " ".join(arr[3:])
|
143
|
+
self.s_print("sql:", s)
|
144
|
+
rst = self.query(s)
|
145
|
+
result = []
|
146
|
+
if len(rst)>0:
|
147
|
+
keys = rst[0]
|
148
|
+
rst = rst[1:]
|
149
|
+
result.append(['"'+v.lower()+'"' for v in keys])
|
150
|
+
for i, obj in zip(range(len(rst)), rst):
|
151
|
+
v = ['"'+str(k)+'"' for k in obj]
|
152
|
+
result.append(v)
|
153
|
+
result = [", ".join(k) for k in result]
|
154
|
+
rs = "\n".join(result)
|
155
|
+
with open(fp, "wb") as f:
|
156
|
+
f.write(rs.encode(cd))
|
157
|
+
self.s_print("done write \"{s}\" to {fp}".format(s = s, fp = fp))
|
158
|
+
elif s == "":
|
159
|
+
return ""
|
160
|
+
else:
|
161
|
+
self.s_print("SQL:", s)
|
162
|
+
try:
|
163
|
+
if self.dv.check_query(s):
|
164
|
+
rst = self.query(s)
|
165
|
+
result = []
|
166
|
+
if len(rst)>0:
|
167
|
+
keys = rst[0]
|
168
|
+
rst = rst[1:]
|
169
|
+
result.append(["KEY"]+keys)
|
170
|
+
for i, obj in zip(range(len(rst)), rst):
|
171
|
+
v = [self.jstr(k) for k in obj]
|
172
|
+
result.append([str(i)]+v)
|
173
|
+
self.s_print(self.format(result))
|
174
|
+
else:
|
175
|
+
rst = self.execute(s)
|
176
|
+
self.s_print(rst)
|
177
|
+
except Exception as exp:
|
178
|
+
import traceback
|
179
|
+
traceback.print_exc()
|
180
|
+
self.s_print("Error sql line:", exp)
|
181
|
+
self.s_print("")
|
182
|
+
return self.s_flush()
|
183
|
+
def run(self):
|
184
|
+
self.begin()
|
185
|
+
try:
|
186
|
+
while True:
|
187
|
+
rst = []
|
188
|
+
while True:
|
189
|
+
s = input(":").strip()
|
190
|
+
if s in "cls, clear".split(","):
|
191
|
+
import os
|
192
|
+
os.system(s)
|
193
|
+
continue
|
194
|
+
rst.append(s)
|
195
|
+
if s.find(";")>=0:
|
196
|
+
break
|
197
|
+
s = " ".join(rst)
|
198
|
+
s = s.split(";")[0].strip()
|
199
|
+
if s == "exit":
|
200
|
+
break
|
201
|
+
rst = self.single(s)
|
202
|
+
print(rst)
|
203
|
+
print("")
|
204
|
+
finally:
|
205
|
+
self.close()
|
206
|
+
|
207
|
+
pass
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
import sys
|
3
|
+
import os
|
4
|
+
import time
|
5
|
+
from buildz import xf
|
6
|
+
FP = "run.conf"
|
7
|
+
def find(arr, k, base = 0):
|
8
|
+
for i in range(base, len(arr)):
|
9
|
+
if arr[i]==k:
|
10
|
+
return i
|
11
|
+
return -1
|
12
|
+
|
13
|
+
pass
|
14
|
+
def test(fp):
|
15
|
+
obj = xf.loads(xf.fread(fp))
|
16
|
+
dv = obj['dv']
|
17
|
+
if __name__ == "__main__":
|
18
|
+
if dv == 'mysql':
|
19
|
+
from dv.mysqlz import build
|
20
|
+
elif dv == 'oracle':
|
21
|
+
from dv.oraclez import build
|
22
|
+
elif dv == 'clickhouse':
|
23
|
+
from dv.clickhousez import build
|
24
|
+
else:
|
25
|
+
if dv == 'mysql':
|
26
|
+
from .dv.mysqlz import build
|
27
|
+
elif dv == 'oracle':
|
28
|
+
from .dv.oraclez import build
|
29
|
+
elif dv == 'clickhouse':
|
30
|
+
from .dv.clickhousez import build
|
31
|
+
db_url = obj['db']
|
32
|
+
db_url = obj[db_url]
|
33
|
+
user = obj['user']
|
34
|
+
pwd = obj['pwd']
|
35
|
+
src = obj['src']
|
36
|
+
out = obj['out']
|
37
|
+
sqls = xf.fread(src)
|
38
|
+
sqls = sqls.replace("\r\n", "\n").rstrip().split("\n")
|
39
|
+
sqls_strip = [k.strip() for k in sqls]
|
40
|
+
i = find(sqls_strip, "!!begin")
|
41
|
+
bi = i
|
42
|
+
if i < 0:
|
43
|
+
bi=0
|
44
|
+
j = find(sqls_strip, "!!end", bi)
|
45
|
+
sqls = sqls[i+1:j]
|
46
|
+
sqls = [k for k in sqls if k.lstrip()[:2]!="--"]
|
47
|
+
sqls = "\n".join(sqls)
|
48
|
+
sqls = sqls.split(";")
|
49
|
+
print(f"[TESTZ] sqls:{sqls}")
|
50
|
+
cmd = build([db_url, user, pwd], obj)
|
51
|
+
cmd.dv.begin()
|
52
|
+
print("[TESTZ] A")
|
53
|
+
with open(out, 'wb') as f:
|
54
|
+
for sql in sqls:
|
55
|
+
if sql.strip()=="":
|
56
|
+
continue
|
57
|
+
if sql.strip() == "exit":
|
58
|
+
break
|
59
|
+
print("[TESTZ] B")
|
60
|
+
rst = cmd.single(sql)
|
61
|
+
print("[TESTZ] C")
|
62
|
+
f.write(rst.encode("utf-8"))
|
63
|
+
cmd.close()
|
64
|
+
|
65
|
+
pass
|
66
|
+
class Runner:
|
67
|
+
def __init__(self, fp):
|
68
|
+
self.fp = fp
|
69
|
+
def init(self):
|
70
|
+
self.obj = xf.loads(xf.fread(self.fp))
|
71
|
+
self.fps = [self.fp, self.obj['src']]
|
72
|
+
self.fps = [os.path.abspath(fp) for fp in self.fps]
|
73
|
+
self.curr = [0,0]
|
74
|
+
def run(self):
|
75
|
+
while True:
|
76
|
+
secs = [os.path.getmtime(fp) for fp in self.fps]
|
77
|
+
if self.curr != secs:
|
78
|
+
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), "done update")
|
79
|
+
self.init()
|
80
|
+
self.curr = secs
|
81
|
+
test(self.fp)
|
82
|
+
time.sleep(float(self.obj['sec']))
|
83
|
+
|
84
|
+
pass
|
85
|
+
|
86
|
+
def run(fp):
|
87
|
+
r = Runner(fp)
|
88
|
+
r.init()
|
89
|
+
r.run()
|
90
|
+
|
91
|
+
pass
|
92
|
+
def main():
|
93
|
+
fp = FP
|
94
|
+
if len(sys.argv)>1:
|
95
|
+
fp = sys.argv[1]
|
96
|
+
return run(fp)
|
97
|
+
|
98
|
+
pass
|
99
|
+
|
100
|
+
if __name__=="__main__":
|
101
|
+
main()
|
102
|
+
|
103
|
+
pass
|
@@ -12,9 +12,13 @@ class Deal:
|
|
12
12
|
ct = argx.get(maps, "c,content".split(","), None)
|
13
13
|
depth = argx.get(maps, "d,depth".split(","), None)
|
14
14
|
out_fp = argx.get(maps, "o,output".split(","), None)
|
15
|
+
show = argx.get(maps, "s,show".split(","), False)
|
16
|
+
prv = int(argx.get(maps, "p,prev".split(","), 10))
|
17
|
+
aft = int(argx.get(maps, "a,aft".split(","), 10))
|
18
|
+
shows = [prv, aft]
|
15
19
|
if depth is not None:
|
16
20
|
depth = int(depth)
|
17
|
-
rst = fz.search(dp, ct_fp, ct, depth)
|
21
|
+
rst = fz.search(dp, ct_fp, ct, depth, show=show, shows=shows)
|
18
22
|
l = len(rst)
|
19
23
|
rs = "\n".join(rst)
|
20
24
|
if out_fp is not None:
|
@@ -81,4 +81,15 @@ def removes(fp, cover = False):
|
|
81
81
|
#print(f"removedirs '{fp}'")
|
82
82
|
os.rmdir(fp)
|
83
83
|
|
84
|
+
pass
|
85
|
+
def decode(s, coding = 'utf-8'):
|
86
|
+
coding = coding.lower()
|
87
|
+
xcoding = 'utf-8'
|
88
|
+
if coding == 'utf-8':
|
89
|
+
xcoding = 'gbk'
|
90
|
+
try:
|
91
|
+
return s.decode(coding)
|
92
|
+
except:
|
93
|
+
return s.decode(xcoding)
|
94
|
+
|
84
95
|
pass
|