cloudoll 2.3.1__tar.gz → 2.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 (46) hide show
  1. {cloudoll-2.3.1 → cloudoll-2.3.2}/PKG-INFO +1 -1
  2. cloudoll-2.3.2/cloudoll/__init__.py +1 -0
  3. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/__init__.py +20 -3
  4. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/base.py +3 -0
  5. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/model.py +117 -113
  6. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/PKG-INFO +1 -1
  7. cloudoll-2.3.1/cloudoll/__init__.py +0 -1
  8. {cloudoll-2.3.1 → cloudoll-2.3.2}/LICENSE +0 -0
  9. {cloudoll-2.3.1 → cloudoll-2.3.2}/README.md +0 -0
  10. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/__main__.py +0 -0
  11. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/cli.py +0 -0
  12. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/error/__init__.py +0 -0
  13. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/error/errors.py +0 -0
  14. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/logging/__init__.py +0 -0
  15. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/mail/__init__.py +0 -0
  16. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/mail/smtp.py +0 -0
  17. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/err.py +0 -0
  18. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/field.py +0 -0
  19. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/mysql.py +0 -0
  20. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/parse.py +0 -0
  21. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/orm/postgres.py +0 -0
  22. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/robot/__init__.py +0 -0
  23. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/robot/dingtalk.py +0 -0
  24. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/robot/feishu.py +0 -0
  25. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/robot/slack.py +0 -0
  26. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/__init__.py +0 -0
  27. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/cli_main.py +0 -0
  28. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/common.py +0 -0
  29. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/m2d.py +0 -0
  30. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/patch_loop.py +0 -0
  31. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/snowflake.py +0 -0
  32. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/utils/watch.py +0 -0
  33. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/__init__.py +0 -0
  34. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/core.py +0 -0
  35. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/exception.py +0 -0
  36. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/html.py +0 -0
  37. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/http.py +0 -0
  38. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/jwt.py +0 -0
  39. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll/web/settings.py +0 -0
  40. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/SOURCES.txt +0 -0
  41. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/dependency_links.txt +0 -0
  42. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/entry_points.txt +0 -0
  43. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/requires.txt +0 -0
  44. {cloudoll-2.3.1 → cloudoll-2.3.2}/cloudoll.egg-info/top_level.txt +0 -0
  45. {cloudoll-2.3.1 → cloudoll-2.3.2}/setup.cfg +0 -0
  46. {cloudoll-2.3.1 → cloudoll-2.3.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 2.3.1
3
+ Version: 2.3.2
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -0,0 +1 @@
1
+ __version__ = "2.3.2"
@@ -84,7 +84,6 @@ class Postgres(MeteBase):
84
84
  elif query_type == QueryTypes.ONE:
85
85
  columns = [desc[0] for desc in cursor.description]
86
86
  row = await cursor.fetchone()
87
- # print("rows_reuslt", rows)
88
87
  result = dict(zip(columns, row)) if row else {}
89
88
  return result
90
89
  elif query_type == QueryTypes.MANY:
@@ -93,7 +92,16 @@ class Postgres(MeteBase):
93
92
  result = [dict(zip(columns, row)) for row in rows]
94
93
  return result
95
94
  elif query_type == QueryTypes.COUNT:
96
- return cursor.rowcount
95
+ result = await cursor.fetchone()
96
+ count = 0
97
+ if rows is None:
98
+ return count
99
+ for row in rows:
100
+ count = rows[row]
101
+ return count
102
+ elif query_type == QueryTypes.GROUP_COUNT:
103
+ result = await cursor.fetchall()
104
+ return 0 if not result else len(result)
97
105
  elif query_type == QueryTypes.CREATE:
98
106
  result = cursor.rowcount > 0
99
107
  id = cursor.lastrowid
@@ -192,7 +200,16 @@ class Mysql(MeteBase):
192
200
  elif query_type == QueryTypes.MANY:
193
201
  return await cursor.fetchmany(size)
194
202
  elif query_type == QueryTypes.COUNT:
195
- return cursor.rowcount
203
+ rows = await cursor.fetchone()
204
+ count = 0
205
+ if rows is None:
206
+ return count
207
+ for row in rows:
208
+ count = rows[row]
209
+ return count
210
+ elif query_type == QueryTypes.GROUP_COUNT:
211
+ result = await cursor.fetchall()
212
+ return 0 if not result else len(result)
196
213
  elif query_type == QueryTypes.CREATE:
197
214
  result = cursor.rowcount > 0
198
215
  id = cursor.lastrowid
@@ -12,6 +12,7 @@ class QueryTypes(Enum):
12
12
  DELETE = 7
13
13
  CREATEBATCH = 8
14
14
  UPDATEBATCH = 9
15
+ GROUP_COUNT = 10
15
16
 
16
17
 
17
18
  class MeteBase:
@@ -60,6 +61,8 @@ class MeteBase:
60
61
 
61
62
  async def count(self, sql, params):
62
63
  return await self.query(sql, params, QueryTypes.COUNT)
64
+ async def group_count(self, sql, params):
65
+ return await self.query(sql, params, QueryTypes.GROUP_COUNT)
63
66
 
64
67
  async def update(self, sql, params):
65
68
  return await self.query(sql, params, QueryTypes.UPDATE)
@@ -228,7 +228,9 @@ class Model(metaclass=ModelMetaclass):
228
228
  for item in args:
229
229
  if isinstance(item, Model):
230
230
  for k in item.__dict__:
231
- if (action == "u" and item[k].value is not None) or action == "i":
231
+ if (
232
+ action == "u" and item[k].value is not None
233
+ ) or action == "i":
232
234
  data[k] = item[k]
233
235
 
234
236
  else: # for object
@@ -463,20 +465,22 @@ class Model(metaclass=ModelMetaclass):
463
465
  sql = f"SELECT COUNT(*) FROM {cls.__table__} {aft}"
464
466
  args = cls.__params__
465
467
  sql = self._exchange_sql(sql)
468
+ if GROUPBY is not None and GROUPBY != "":
469
+ return await cls.__pool__.group_count(sql, args)
466
470
  return await cls.__pool__.count(sql, args)
467
471
 
468
472
 
469
473
  class Models(object):
470
474
  class CharField(Field):
471
475
  def __init__(
472
- self,
473
- name=None,
474
- primary_key=False,
475
- default=None,
476
- charset=None,
477
- max_length=None,
478
- not_null=False,
479
- comment=None,
476
+ self,
477
+ name=None,
478
+ primary_key=False,
479
+ default=None,
480
+ charset=None,
481
+ max_length=None,
482
+ not_null=False,
483
+ comment=None,
480
484
  ):
481
485
  super().__init__(
482
486
  name,
@@ -491,14 +495,14 @@ class Models(object):
491
495
 
492
496
  class VarCharField(Field):
493
497
  def __init__(
494
- self,
495
- name=None,
496
- primary_key=False,
497
- default=None,
498
- charset=None,
499
- max_length=None,
500
- not_null=False,
501
- comment=None,
498
+ self,
499
+ name=None,
500
+ primary_key=False,
501
+ default=None,
502
+ charset=None,
503
+ max_length=None,
504
+ not_null=False,
505
+ comment=None,
502
506
  ):
503
507
  super().__init__(
504
508
  name,
@@ -513,7 +517,7 @@ class Models(object):
513
517
 
514
518
  class BooleanField(Field):
515
519
  def __init__(
516
- self, name=None, default=False, not_null=False, comment=None, unsigned=False
520
+ self, name=None, default=False, not_null=False, comment=None, unsigned=False
517
521
  ):
518
522
  super().__init__(
519
523
  name,
@@ -526,15 +530,15 @@ class Models(object):
526
530
 
527
531
  class IntegerField(Field):
528
532
  def __init__(
529
- self,
530
- name=None,
531
- primary_key=False,
532
- default=None,
533
- auto_increment=False,
534
- not_null=False,
535
- unsigned=False,
536
- comment=None,
537
- max_length=None,
533
+ self,
534
+ name=None,
535
+ primary_key=False,
536
+ default=None,
537
+ auto_increment=False,
538
+ not_null=False,
539
+ unsigned=False,
540
+ comment=None,
541
+ max_length=None,
538
542
  ):
539
543
  super().__init__(
540
544
  name,
@@ -550,15 +554,15 @@ class Models(object):
550
554
 
551
555
  class BigIntegerField(Field):
552
556
  def __init__(
553
- self,
554
- name=None,
555
- primary_key=False,
556
- default=None,
557
- auto_increment=False,
558
- not_null=False,
559
- unsigned=False,
560
- comment=None,
561
- max_length=None,
557
+ self,
558
+ name=None,
559
+ primary_key=False,
560
+ default=None,
561
+ auto_increment=False,
562
+ not_null=False,
563
+ unsigned=False,
564
+ comment=None,
565
+ max_length=None,
562
566
  ):
563
567
  super().__init__(
564
568
  name,
@@ -574,13 +578,13 @@ class Models(object):
574
578
 
575
579
  class DoubleField(Field):
576
580
  def __init__(
577
- self,
578
- name=None,
579
- default=None,
580
- not_null=False,
581
- max_length=None,
582
- unsigned=False,
583
- comment=None,
581
+ self,
582
+ name=None,
583
+ default=None,
584
+ not_null=False,
585
+ max_length=None,
586
+ unsigned=False,
587
+ comment=None,
584
588
  ):
585
589
  super().__init__(
586
590
  name,
@@ -594,14 +598,14 @@ class Models(object):
594
598
 
595
599
  class FloatField(Field):
596
600
  def __init__(
597
- self,
598
- name=None,
599
- default=None,
600
- not_null=False,
601
- max_length=None,
602
- scale_length=None,
603
- unsigned=False,
604
- comment=None,
601
+ self,
602
+ name=None,
603
+ default=None,
604
+ not_null=False,
605
+ max_length=None,
606
+ scale_length=None,
607
+ unsigned=False,
608
+ comment=None,
605
609
  ):
606
610
  super().__init__(
607
611
  name,
@@ -616,14 +620,14 @@ class Models(object):
616
620
 
617
621
  class NumericField(Field):
618
622
  def __init__(
619
- self,
620
- name=None,
621
- default=0.0,
622
- not_null=False,
623
- max_length=None,
624
- scale_length=None,
625
- unsigned=False,
626
- comment=None,
623
+ self,
624
+ name=None,
625
+ default=0.0,
626
+ not_null=False,
627
+ max_length=None,
628
+ scale_length=None,
629
+ unsigned=False,
630
+ comment=None,
627
631
  ):
628
632
  super().__init__(
629
633
  name,
@@ -638,14 +642,14 @@ class Models(object):
638
642
 
639
643
  class DecimalField(Field):
640
644
  def __init__(
641
- self,
642
- name=None,
643
- default=0.0,
644
- not_null=False,
645
- max_length=None,
646
- scale_length=None,
647
- unsigned=False,
648
- comment=None,
645
+ self,
646
+ name=None,
647
+ default=0.0,
648
+ not_null=False,
649
+ max_length=None,
650
+ scale_length=None,
651
+ unsigned=False,
652
+ comment=None,
649
653
  ):
650
654
  super().__init__(
651
655
  name,
@@ -660,13 +664,13 @@ class Models(object):
660
664
 
661
665
  class TextField(Field):
662
666
  def __init__(
663
- self,
664
- name=None,
665
- default=None,
666
- charset=None,
667
- max_length=None,
668
- not_null=False,
669
- comment=None,
667
+ self,
668
+ name=None,
669
+ default=None,
670
+ charset=None,
671
+ max_length=None,
672
+ not_null=False,
673
+ comment=None,
670
674
  ):
671
675
  super().__init__(
672
676
  name,
@@ -680,13 +684,13 @@ class Models(object):
680
684
 
681
685
  class LongTextField(Field):
682
686
  def __init__(
683
- self,
684
- name=None,
685
- default=None,
686
- charset=None,
687
- max_length=None,
688
- not_null=False,
689
- comment=None,
687
+ self,
688
+ name=None,
689
+ default=None,
690
+ charset=None,
691
+ max_length=None,
692
+ not_null=False,
693
+ comment=None,
690
694
  ):
691
695
  super().__init__(
692
696
  name,
@@ -700,13 +704,13 @@ class Models(object):
700
704
 
701
705
  class MediumTextField(Field):
702
706
  def __init__(
703
- self,
704
- name=None,
705
- default=None,
706
- charset=None,
707
- max_length=None,
708
- not_null=False,
709
- comment=None,
707
+ self,
708
+ name=None,
709
+ default=None,
710
+ charset=None,
711
+ max_length=None,
712
+ not_null=False,
713
+ comment=None,
710
714
  ):
711
715
  super().__init__(
712
716
  name,
@@ -720,14 +724,14 @@ class Models(object):
720
724
 
721
725
  class DatetimeField(Field):
722
726
  def __init__(
723
- self,
724
- name=None,
725
- default=None,
726
- max_length=None,
727
- not_null=False,
728
- created_generated=False,
729
- update_generated=False,
730
- comment=None,
727
+ self,
728
+ name=None,
729
+ default=None,
730
+ max_length=None,
731
+ not_null=False,
732
+ created_generated=False,
733
+ update_generated=False,
734
+ comment=None,
731
735
  ):
732
736
  super().__init__(
733
737
  name,
@@ -742,14 +746,14 @@ class Models(object):
742
746
 
743
747
  class DateField(Field):
744
748
  def __init__(
745
- self,
746
- name=None,
747
- default=None,
748
- max_length=None,
749
- not_null=False,
750
- created_generated=False,
751
- update_generated=False,
752
- comment=None,
749
+ self,
750
+ name=None,
751
+ default=None,
752
+ max_length=None,
753
+ not_null=False,
754
+ created_generated=False,
755
+ update_generated=False,
756
+ comment=None,
753
757
  ):
754
758
  super().__init__(
755
759
  name,
@@ -764,14 +768,14 @@ class Models(object):
764
768
 
765
769
  class TimestampField(Field):
766
770
  def __init__(
767
- self,
768
- name=None,
769
- default=None,
770
- max_length=None,
771
- not_null=False,
772
- created_generated=False,
773
- update_generated=False,
774
- comment=None,
771
+ self,
772
+ name=None,
773
+ default=None,
774
+ max_length=None,
775
+ not_null=False,
776
+ created_generated=False,
777
+ update_generated=False,
778
+ comment=None,
775
779
  ):
776
780
  super().__init__(
777
781
  name,
@@ -787,7 +791,7 @@ class Models(object):
787
791
 
788
792
  class JsonField(Field):
789
793
  def __init__(
790
- self, name=None, default=None, charset=None, not_null=False, comment=None
794
+ self, name=None, default=None, charset=None, not_null=False, comment=None
791
795
  ):
792
796
  super().__init__(
793
797
  name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudoll
3
- Version: 2.3.1
3
+ Version: 2.3.2
4
4
  Summary: 辅助快速创建可分布的微服务。
5
5
  Home-page: https://gitee.com/chuchur/cloudoll-py
6
6
  Author: chuchur
@@ -1 +0,0 @@
1
- __version__ = "2.3.1"
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