cloudoll 2.2.24__tar.gz → 2.2.26__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.
- {cloudoll-2.2.24 → cloudoll-2.2.26}/PKG-INFO +14 -1
- cloudoll-2.2.26/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/__init__.py +1 -1
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/field.py +62 -35
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/model.py +6 -3
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/PKG-INFO +14 -1
- cloudoll-2.2.24/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.24 → cloudoll-2.2.26}/LICENSE +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/README.md +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/cli.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/snowflake.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/utils/watch.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/__init__.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll/web/settings.py +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/setup.cfg +0 -0
- {cloudoll-2.2.24 → cloudoll-2.2.26}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.26
|
|
4
4
|
Summary: 辅助快速创建可分布的微服务。
|
|
5
5
|
Home-page: https://gitee.com/chuchur/cloudoll-py
|
|
6
6
|
Author: chuchur
|
|
@@ -15,6 +15,19 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
15
15
|
Requires-Python: >=3.6.0
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
+
Requires-Dist: watchfiles
|
|
19
|
+
Requires-Dist: curl_cffi
|
|
20
|
+
Requires-Dist: colorlog
|
|
21
|
+
Requires-Dist: aiomysql
|
|
22
|
+
Requires-Dist: aiopg
|
|
23
|
+
Requires-Dist: aiohttp
|
|
24
|
+
Requires-Dist: redis[hiredis]
|
|
25
|
+
Requires-Dist: aiomcache
|
|
26
|
+
Requires-Dist: jinja2
|
|
27
|
+
Requires-Dist: pyjwt
|
|
28
|
+
Requires-Dist: aiohttp_session[secure]
|
|
29
|
+
Requires-Dist: PyYAML
|
|
30
|
+
Requires-Dist: click
|
|
18
31
|
|
|
19
32
|
|
|
20
33
|
# cloudoll 云端玩具
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.26"
|
|
@@ -115,7 +115,7 @@ class Postgres(MeteBase):
|
|
|
115
115
|
# self.pool.release(cursor)
|
|
116
116
|
|
|
117
117
|
async def query(self, sql, params=None, query_type: QueryTypes = 2, size: int = 10):
|
|
118
|
-
sql = sql.replace("?", "%s").replace(
|
|
118
|
+
sql = sql.replace("?", "%s").replace('`', '"')
|
|
119
119
|
print_info("sql", sql, params)
|
|
120
120
|
if not self.pool:
|
|
121
121
|
raise ValueError("must be create_engine first.")
|
|
@@ -35,13 +35,18 @@ OP = objdict(
|
|
|
35
35
|
IS_THIS_WEEK="THIS_WEEK",
|
|
36
36
|
IS_THIS_MONTH="THIS_MONTH",
|
|
37
37
|
IS_THIS_YEAR="THIS_YEAR",
|
|
38
|
+
LASTED_HOURS="LASTED_HOURS",
|
|
39
|
+
LASTED_MINUTES="LASTED_MINUTES",
|
|
40
|
+
LASTED_SECONDS="LASTED_SECONDS",
|
|
41
|
+
LASTED_YEARS="LASTED_YEARS",
|
|
42
|
+
LASTED_MONTHS="LASTED_MONTHS",
|
|
43
|
+
LASTED_DAYS="LASTED_DAYS",
|
|
44
|
+
BEFORE_YEARS="BEFORE_YEARS",
|
|
45
|
+
BEFORE_MONTHS="BEFORE_MONTHS",
|
|
38
46
|
BEFORE_DAYS="BEFORE_DAYS",
|
|
39
47
|
BEFORE_HOURS="BEFORE_HOURS",
|
|
40
48
|
BEFORE_MINUTES="BEFORE_MINUTES",
|
|
41
|
-
|
|
42
|
-
AFTER_YEARS="AFTER_YEARS",
|
|
43
|
-
AFTER_MONTHS="AFTER_MONTHS",
|
|
44
|
-
BEFORE_MONTHS="BEFORE_MONTHS",
|
|
49
|
+
BEFORE_SECONDS="BEFORE_SECONDS",
|
|
45
50
|
DATE_FORMAT="DATE_FORMAT",
|
|
46
51
|
JSON_CONTAINS_OBJECT="JSON_CONTAINS_OBJECT",
|
|
47
52
|
JSON_CONTAINS_ARRAY="JSON_CONTAINS_ARRAY",
|
|
@@ -138,6 +143,30 @@ class FieldBase(object):
|
|
|
138
143
|
def is_this_year(self):
|
|
139
144
|
return Function(self, OP.IS_THIS_YEAR)
|
|
140
145
|
|
|
146
|
+
def lasted_hours(self, args):
|
|
147
|
+
return Function(self, OP.LASTED_HOURS, args)
|
|
148
|
+
|
|
149
|
+
def lasted_minutes(self, args):
|
|
150
|
+
return Function(self, OP.LASTED_MINUTES, args)
|
|
151
|
+
|
|
152
|
+
def lasted_seconds(self, args):
|
|
153
|
+
return Function(self, OP.LASTED_SECONDS, args)
|
|
154
|
+
|
|
155
|
+
def lasted_years(self, args):
|
|
156
|
+
return Function(self, OP.LASTED_YEARS, args)
|
|
157
|
+
|
|
158
|
+
def lasted_months(self, args):
|
|
159
|
+
return Function(self, OP.LASTED_MONTHS, args)
|
|
160
|
+
|
|
161
|
+
def lasted_days(self, args):
|
|
162
|
+
return Function(self, OP.LASTED_DAYS, args)
|
|
163
|
+
|
|
164
|
+
def before_months(self, args):
|
|
165
|
+
return Function(self, OP.BEFORE_MONTHS, args)
|
|
166
|
+
|
|
167
|
+
def before_years(self, args):
|
|
168
|
+
return Function(self, OP.BEFORE_YEARS, args)
|
|
169
|
+
|
|
141
170
|
def before_days(self, args):
|
|
142
171
|
return Function(self, OP.BEFORE_DAYS, args)
|
|
143
172
|
|
|
@@ -147,17 +176,8 @@ class FieldBase(object):
|
|
|
147
176
|
def before_minutes(self, args):
|
|
148
177
|
return Function(self, OP.BEFORE_MINUTES, args)
|
|
149
178
|
|
|
150
|
-
def
|
|
151
|
-
return Function(self, OP.
|
|
152
|
-
|
|
153
|
-
def before_months(self, args):
|
|
154
|
-
return Function(self, OP.BEFORE_MONTHS, args)
|
|
155
|
-
|
|
156
|
-
def after_months(self, args):
|
|
157
|
-
return Function(self, OP.AFTER_MONTHS, args)
|
|
158
|
-
|
|
159
|
-
def after_years(self, args):
|
|
160
|
-
return Function(self, OP.AFTER_YEARS, args)
|
|
179
|
+
def before_seconds(self, args):
|
|
180
|
+
return Function(self, OP.BEFORE_SECOBDS, args)
|
|
161
181
|
|
|
162
182
|
def json_contains_object(self, key, value):
|
|
163
183
|
return Function(self, OP.JSON_CONTAINS_OBJECT, (key, value))
|
|
@@ -238,20 +258,33 @@ class Function(FieldBase):
|
|
|
238
258
|
return f"MONTH({col_name}) = MONTH(CURDATE())", None
|
|
239
259
|
elif op == OP.IS_THIS_YEAR:
|
|
240
260
|
return f"YEAR({col_name}) = YEAR(CURDATE())", None
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
elif op == OP.BEFORE_MINUTES:
|
|
261
|
+
|
|
262
|
+
elif op == OP.LASTED_SECONDS:
|
|
263
|
+
return f"{col_name} >= NOW() - INTERVAL {self.rpt} SECOND", None
|
|
264
|
+
elif op == OP.LASTED_MINUTES:
|
|
246
265
|
return f"{col_name} >= NOW() - INTERVAL {self.rpt} MINUTE", None
|
|
266
|
+
elif op == OP.LASTED_HOURS:
|
|
267
|
+
return f"{col_name} >= NOW() - INTERVAL {self.rpt} HOUR", None
|
|
268
|
+
elif op == OP.LASTED_YEARS:
|
|
269
|
+
return f"{col_name} >= NOW() - INTERVAL {self.rpt} YEAR", None
|
|
270
|
+
elif op == OP.LASTED_MONTHS:
|
|
271
|
+
return f"{col_name} >= NOW() - INTERVAL {self.rpt} MONTH", None
|
|
272
|
+
elif op == OP.LASTED_DAYS:
|
|
273
|
+
return f"DATE({col_name}) >= CURDATE() - INTERVAL {self.rpt} DAY", None
|
|
274
|
+
|
|
247
275
|
elif op == OP.BEFORE_YEARS:
|
|
248
|
-
return f"{col_name}
|
|
276
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} YEAR", None
|
|
249
277
|
elif op == OP.BEFORE_MONTHS:
|
|
250
|
-
return f"{col_name}
|
|
251
|
-
elif op == OP.
|
|
252
|
-
return f"{col_name} <
|
|
253
|
-
elif op == OP.
|
|
254
|
-
return f"{col_name} <
|
|
278
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} MONTH", None
|
|
279
|
+
elif op == OP.BEFORE_DAYS:
|
|
280
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} DAY", None
|
|
281
|
+
elif op == OP.BEFORE_HOURS:
|
|
282
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} HOUR", None
|
|
283
|
+
elif op == OP.BEFORE_MINUTES:
|
|
284
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} MINUTE", None
|
|
285
|
+
elif op == OP.BEFORE_SECONDS:
|
|
286
|
+
return f"{col_name} < NOW() - INTERVAL {self.rpt} SECOND", None
|
|
287
|
+
|
|
255
288
|
elif op == OP.JSON_CONTAINS_OBJECT:
|
|
256
289
|
_k, _v = self.rpt
|
|
257
290
|
key = _k.full_name if isinstance(_k, Field) else f"'{_k}'"
|
|
@@ -301,33 +334,28 @@ class Expression(FieldBase):
|
|
|
301
334
|
q.append(_q)
|
|
302
335
|
if _p:
|
|
303
336
|
p = p + _p
|
|
304
|
-
# return l.sql()
|
|
305
337
|
|
|
306
338
|
q.append(f" {self.op} ")
|
|
307
339
|
|
|
308
340
|
if isinstance(r, Field):
|
|
309
341
|
if r._value is not None:
|
|
310
|
-
# _value = r._value if r._value is not None else r.full_name
|
|
311
342
|
q.append("?")
|
|
312
343
|
p.append(r._value)
|
|
313
344
|
else:
|
|
314
345
|
q.append(r.full_name)
|
|
315
|
-
# q.append(str(r._value) if r._value is not None else r.full_name)
|
|
316
346
|
elif isinstance(r, FieldBase):
|
|
317
347
|
_q, _p = r.sql()
|
|
318
348
|
q.append(_q)
|
|
319
|
-
|
|
349
|
+
if _p:
|
|
350
|
+
p = p + _p
|
|
320
351
|
elif self.op == OP.AS:
|
|
321
|
-
# is_fun or (isinstance(r, str) and (self.op == OP.AND or self.op == OP.OR)):
|
|
322
352
|
q.append(r)
|
|
323
353
|
elif r is not None:
|
|
324
354
|
q.append("?")
|
|
325
355
|
p.append(r)
|
|
326
356
|
if not is_fun:
|
|
327
357
|
q.append(")")
|
|
328
|
-
# q.append(")")
|
|
329
358
|
q = [str(num) for num in q]
|
|
330
|
-
# print("".join(q))
|
|
331
359
|
return "".join(q), p
|
|
332
360
|
|
|
333
361
|
# def __str__(self):
|
|
@@ -338,7 +366,6 @@ class Expression(FieldBase):
|
|
|
338
366
|
# return str(eval(f"{cal}{self.rhs}"))
|
|
339
367
|
|
|
340
368
|
def __repr__(self):
|
|
341
|
-
# return self.__value
|
|
342
369
|
cal = f"{self.lhs.value}{self.op}"
|
|
343
370
|
if isinstance(self.rhs, FieldBase):
|
|
344
371
|
return str(eval(f"{cal}{self.rhs.value}"))
|
|
@@ -354,7 +381,7 @@ class Field(FieldBase):
|
|
|
354
381
|
primary_key=False, # 主键
|
|
355
382
|
charset=None, # 编码
|
|
356
383
|
max_length=None, # 长度
|
|
357
|
-
scale_length=None,
|
|
384
|
+
scale_length=None, # 精度
|
|
358
385
|
auto_increment=False, # 自增
|
|
359
386
|
NOT_NULL=False, # 非空
|
|
360
387
|
created_generated=False, # 创建时for datetime
|
|
@@ -392,7 +392,8 @@ class Model(metaclass=ModelMetaclass):
|
|
|
392
392
|
sql = f"update `{table}` set {keys} {where}"
|
|
393
393
|
|
|
394
394
|
if where is not None and where != "":
|
|
395
|
-
|
|
395
|
+
if self.__params__:
|
|
396
|
+
params += self.__params__
|
|
396
397
|
else:
|
|
397
398
|
pk, pkv = self._get_primary()
|
|
398
399
|
if pkv is None:
|
|
@@ -434,7 +435,8 @@ class Model(metaclass=ModelMetaclass):
|
|
|
434
435
|
async def insert(self, *args, **kw):
|
|
435
436
|
table = self.__table__
|
|
436
437
|
keys, params = self._get_insert_key_args("i", args or kw)
|
|
437
|
-
|
|
438
|
+
escape_keys = [f'`{k}`' for k in keys]
|
|
439
|
+
sql = f"insert into `{table}` ({','.join(escape_keys)}) values ({','.join(['?' for k in keys])})"
|
|
438
440
|
self._reset()
|
|
439
441
|
params = tuple(key for key in params)
|
|
440
442
|
return await self.__pool__.create(sql, params)
|
|
@@ -444,7 +446,8 @@ class Model(metaclass=ModelMetaclass):
|
|
|
444
446
|
if len(items) == 0:
|
|
445
447
|
return 0
|
|
446
448
|
keys, params = self._get_batch_keys_values(items)
|
|
447
|
-
|
|
449
|
+
escape_keys = [f'`{k}`' for k in keys]
|
|
450
|
+
sql = f"insert into `{table}` ({','.join(escape_keys)}) values ({','.join(['?' for k in keys])})"
|
|
448
451
|
self._reset()
|
|
449
452
|
return await self.__pool__.create_batch(sql, params)
|
|
450
453
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.26
|
|
4
4
|
Summary: 辅助快速创建可分布的微服务。
|
|
5
5
|
Home-page: https://gitee.com/chuchur/cloudoll-py
|
|
6
6
|
Author: chuchur
|
|
@@ -15,6 +15,19 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
15
15
|
Requires-Python: >=3.6.0
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
+
Requires-Dist: watchfiles
|
|
19
|
+
Requires-Dist: curl_cffi
|
|
20
|
+
Requires-Dist: colorlog
|
|
21
|
+
Requires-Dist: aiomysql
|
|
22
|
+
Requires-Dist: aiopg
|
|
23
|
+
Requires-Dist: aiohttp
|
|
24
|
+
Requires-Dist: redis[hiredis]
|
|
25
|
+
Requires-Dist: aiomcache
|
|
26
|
+
Requires-Dist: jinja2
|
|
27
|
+
Requires-Dist: pyjwt
|
|
28
|
+
Requires-Dist: aiohttp_session[secure]
|
|
29
|
+
Requires-Dist: PyYAML
|
|
30
|
+
Requires-Dist: click
|
|
18
31
|
|
|
19
32
|
|
|
20
33
|
# cloudoll 云端玩具
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.24"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|