kaqing 2.0.34__py3-none-any.whl → 2.0.36__py3-none-any.whl
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.
- adam/commands/command.py +1 -0
- adam/commands/postgres/postgres.py +30 -23
- adam/commands/postgres/postgres_session.py +1 -1
- adam/version.py +1 -1
- {kaqing-2.0.34.dist-info → kaqing-2.0.36.dist-info}/METADATA +1 -1
- {kaqing-2.0.34.dist-info → kaqing-2.0.36.dist-info}/RECORD +9 -9
- {kaqing-2.0.34.dist-info → kaqing-2.0.36.dist-info}/WHEEL +0 -0
- {kaqing-2.0.34.dist-info → kaqing-2.0.36.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.34.dist-info → kaqing-2.0.36.dist-info}/top_level.txt +0 -0
adam/commands/command.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import functools
|
1
2
|
import click
|
2
3
|
|
3
4
|
from adam.commands.command import Command
|
@@ -29,30 +30,22 @@ class Postgres(Command):
|
|
29
30
|
|
30
31
|
state, args = self.apply_state(args, state)
|
31
32
|
|
32
|
-
if
|
33
|
-
if
|
33
|
+
if not args:
|
34
|
+
if state.in_repl:
|
34
35
|
log2('Please use SQL statement. e.g. pg \l')
|
35
|
-
|
36
|
-
return 'command-missing'
|
37
36
|
else:
|
38
|
-
self.run_sql(state, args)
|
39
|
-
else:
|
40
|
-
if not args:
|
41
37
|
log2('* Command or SQL statements is missing.')
|
42
38
|
Command.display_help()
|
43
39
|
|
44
|
-
|
45
|
-
else:
|
46
|
-
# head with the Chain of Responsibility pattern
|
47
|
-
cmds = Command.chain(Postgres.cmd_list())
|
48
|
-
if not cmds.run(cmd, state) :
|
49
|
-
if not args:
|
50
|
-
log2('* Command or SQL statements is missing.')
|
51
|
-
Command.display_help()
|
40
|
+
return 'command-missing'
|
52
41
|
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
if state.in_repl:
|
43
|
+
self.run_sql(state, args)
|
44
|
+
else:
|
45
|
+
# head with the Chain of Responsibility pattern
|
46
|
+
cmds = Command.chain(Postgres.cmd_list())
|
47
|
+
if not cmds.run(cmd, state) :
|
48
|
+
self.run_sql(state, args)
|
56
49
|
|
57
50
|
return state
|
58
51
|
|
@@ -72,16 +65,21 @@ class Postgres(Command):
|
|
72
65
|
|
73
66
|
def completion(self, state: ReplState):
|
74
67
|
leaf = {}
|
75
|
-
|
68
|
+
session = PostgresSession(state.namespace, state.pg_path)
|
69
|
+
if session.db:
|
70
|
+
ts = self.tables(state.namespace, state.pg_path)
|
76
71
|
leaf = {
|
77
72
|
'\h': None,
|
78
73
|
'\d': None,
|
79
74
|
'\dt': None,
|
80
75
|
'\du': None,
|
81
|
-
'delete': {'from': None},
|
82
|
-
'insert': {'into': None},
|
83
|
-
'select':
|
84
|
-
|
76
|
+
'delete': {'from': {t: {'where': {'id': {'=': None}}} for t in ts}},
|
77
|
+
'insert': {'into': {t: {'values': None} for t in ts}},
|
78
|
+
'select': {'*': {'from': {t: {
|
79
|
+
'limit': {'1': None},
|
80
|
+
'where': {'id': {'=': None}}
|
81
|
+
} for t in ts}}},
|
82
|
+
'update': {t: {'set': None} for t in ts},
|
85
83
|
}
|
86
84
|
elif state.pg_path:
|
87
85
|
leaf = {
|
@@ -94,6 +92,15 @@ class Postgres(Command):
|
|
94
92
|
else:
|
95
93
|
return {}
|
96
94
|
|
95
|
+
# TODO fix cache
|
96
|
+
# @functools.lru_cache()
|
97
|
+
def tables(self, ns: str, pg_path: str):
|
98
|
+
session = PostgresSession(ns, pg_path)
|
99
|
+
if session.db:
|
100
|
+
return [f'{t["schema"]}.{t["name"]}' for t in session.tables()]
|
101
|
+
|
102
|
+
return []
|
103
|
+
|
97
104
|
def help(self, _: ReplState):
|
98
105
|
return f'[{Postgres.COMMAND}] <sql-statements>\t run psql with queries'
|
99
106
|
|
adam/version.py
CHANGED
@@ -14,7 +14,7 @@ adam/repl_commands.py,sha256=aH7xxbsQGrpL9Ozk9QF54iToK6wbDT3Pu9rMyw9sDBY,4719
|
|
14
14
|
adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
|
15
15
|
adam/repl_state.py,sha256=591d7gV6uQSFtm7IWdlIYAHjfAzs9bdvIkwlIAeKddE,7540
|
16
16
|
adam/utils.py,sha256=2DoWsrcaioFFH0-RjT30qelVRPUJqCGTfz_ucfE7F8g,7406
|
17
|
-
adam/version.py,sha256=
|
17
|
+
adam/version.py,sha256=QO2Crpkw7GxhSSHxm2y2x-87sCIZ3DvMpnEXfvQbBoY,139
|
18
18
|
adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
|
20
20
|
adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
|
@@ -54,7 +54,7 @@ adam/commands/bash.py,sha256=1O9cCl9JHQdttqNAgdB44rO0NjCqHzHv4psAEQMJcjw,2714
|
|
54
54
|
adam/commands/cd.py,sha256=XEoiMhbJgA2KVKwhHFcs5BRAlf9qpgbAh6IImpKOtHI,4486
|
55
55
|
adam/commands/check.py,sha256=853FPfgTMGxQXI_5UaPAtzaSWB_BvEVm48EkJhsHe4w,2181
|
56
56
|
adam/commands/cli_commands.py,sha256=PEEyrG9yz7RAEZwHbbuFpyE3fVi8vrIWbr0d1H0Gp9o,3620
|
57
|
-
adam/commands/command.py,sha256=
|
57
|
+
adam/commands/command.py,sha256=Ph7IduCTGQ04dcwNegl1ekYbqCzOwAOYeWZVIRWnKyU,3958
|
58
58
|
adam/commands/command_helpers.py,sha256=leOJJK1UXczNTJHN9TGMCbIpUpmpreULvQ-TvnsYS7w,1134
|
59
59
|
adam/commands/commands_utils.py,sha256=ShUcxtDSd9B3NM0GDj3NBvKdmjCGY8qXgeUJpzNF63E,3122
|
60
60
|
adam/commands/cp.py,sha256=dyQViRDPNqsKRkxPb7WyEVIBNw7YB6IfYa2q3VtfzyA,3107
|
@@ -104,10 +104,10 @@ adam/commands/medusa/medusa_restore.py,sha256=MU47bmozrjfGJ6GVkj_OVgLH6Uz_fGh03M
|
|
104
104
|
adam/commands/medusa/medusa_show_backupjobs.py,sha256=QekHpKezVJdgfa9hOxfgyx-y4D08tmHzyu_AAa8QPR0,1756
|
105
105
|
adam/commands/medusa/medusa_show_restorejobs.py,sha256=wgPonSmC6buDIp3k3WUY-Yu2MyP1xyE3Q_XhvAwpnx4,1651
|
106
106
|
adam/commands/postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
107
|
-
adam/commands/postgres/postgres.py,sha256=
|
107
|
+
adam/commands/postgres/postgres.py,sha256=zi6zicBLe2ZM6UCZgL3L3tdKIISEMGAh8UFcTuTUp5k,3649
|
108
108
|
adam/commands/postgres/postgres_ls.py,sha256=HwZTgwGKXUqHX33S8aQPF6FqCrLqtoz4cLyJV2SpoE0,1186
|
109
109
|
adam/commands/postgres/postgres_preview.py,sha256=MLzdEc4mvNj6V1Q8jO5OPznXyYELJHgd35_eQgLlNIU,1274
|
110
|
-
adam/commands/postgres/postgres_session.py,sha256=
|
110
|
+
adam/commands/postgres/postgres_session.py,sha256=CK5rkYcRHZqg2AR3fRrP81zF5P71yroPV7SvyQ6pJ7c,9509
|
111
111
|
adam/commands/reaper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
112
112
|
adam/commands/reaper/reaper.py,sha256=83R0ZRitEwaYKKssfKxn3zAzLnWIP9QKd1mA6awceS8,1908
|
113
113
|
adam/commands/reaper/reaper_forward.py,sha256=mUp409MzT91cVXGxoPfBGceaR3qZ0rVdWKGdyzPNzSA,3177
|
@@ -167,8 +167,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
|
|
167
167
|
adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
|
168
168
|
adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
|
169
169
|
adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
|
170
|
-
kaqing-2.0.
|
171
|
-
kaqing-2.0.
|
172
|
-
kaqing-2.0.
|
173
|
-
kaqing-2.0.
|
174
|
-
kaqing-2.0.
|
170
|
+
kaqing-2.0.36.dist-info/METADATA,sha256=QOkTjiMzYzK9hFk11nQ015VPw4umdn7pkOFfoEm0zZc,132
|
171
|
+
kaqing-2.0.36.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
172
|
+
kaqing-2.0.36.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
|
173
|
+
kaqing-2.0.36.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
|
174
|
+
kaqing-2.0.36.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|