cloudoll 3.0.7__tar.gz → 3.0.9__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-3.0.7 → cloudoll-3.0.9}/PKG-INFO +1 -1
- cloudoll-3.0.9/cloudoll/__init__.py +1 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/__init__.py +5 -2
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/awsmysql.py +2 -2
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/awspostgres.py +9 -21
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/field.py +7 -4
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/mysql.py +1 -1
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/postgres.py +8 -16
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/test_sql.py +16 -1
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/PKG-INFO +1 -1
- {cloudoll-3.0.7 → cloudoll-3.0.9}/pyproject.toml +1 -1
- cloudoll-3.0.7/cloudoll/__init__.py +0 -1
- {cloudoll-3.0.7 → cloudoll-3.0.9}/LICENSE +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/README.md +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/__main__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/cli.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/cli_main.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/m2d.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/process.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/spinner.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/clitool/watch.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/base.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/err.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/model.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/orm/parse.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/template/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/utils/common.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/utils/snowflake.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/__init__.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/core.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/exception.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/html.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/jwt.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/requests.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll/web/settings.py +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/setup.cfg +0 -0
- {cloudoll-3.0.7 → cloudoll-3.0.9}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.9
|
|
4
4
|
Summary: Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use.
|
|
5
5
|
Home-page: https://github.com/smallerqiu/cloudoll-py
|
|
6
6
|
Author: Qiu
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.0.9"
|
|
@@ -3,8 +3,7 @@ from cloudoll.orm.parse import parse_coon
|
|
|
3
3
|
import aiopg as pg
|
|
4
4
|
from .mysql import Mysql
|
|
5
5
|
from .postgres import Postgres
|
|
6
|
-
|
|
7
|
-
from .awsmysql import AwsMysql
|
|
6
|
+
|
|
8
7
|
|
|
9
8
|
__all__ = ["create_engine"]
|
|
10
9
|
|
|
@@ -27,8 +26,12 @@ async def create_engine(**kw):
|
|
|
27
26
|
if driver == "mysql":
|
|
28
27
|
return await Mysql().create_engine(**configs, **query)
|
|
29
28
|
elif driver == "aws-mysql":
|
|
29
|
+
from .awsmysql import AwsMysql
|
|
30
|
+
|
|
30
31
|
return await AwsMysql().create_engine(**configs, **query)
|
|
31
32
|
elif driver in ["aws-postgres", "aws-postgressql"]:
|
|
33
|
+
from .awspostgres import AwsPostgres
|
|
34
|
+
|
|
32
35
|
return await AwsPostgres().create_engine(**configs, **query)
|
|
33
36
|
elif driver in ["postgres", "postgressql"]:
|
|
34
37
|
return await Postgres().create_engine(**configs, **query)
|
|
@@ -34,7 +34,7 @@ class AwsMysql(MeteBase):
|
|
|
34
34
|
with AwsWrapperConnection.connect(
|
|
35
35
|
Connect, self._dsn, **self._params
|
|
36
36
|
) as conn:
|
|
37
|
-
with conn.cursor() as cursor:
|
|
37
|
+
with conn.cursor(dictionary=True) as cursor:
|
|
38
38
|
if (
|
|
39
39
|
query_type == QueryTypes.CREATEBATCH
|
|
40
40
|
or query_type == QueryTypes.UPDATEBATCH
|
|
@@ -75,5 +75,5 @@ class AwsMysql(MeteBase):
|
|
|
75
75
|
elif query_type == QueryTypes.DELETE:
|
|
76
76
|
return cursor.rowcount > 0
|
|
77
77
|
except Exception as e:
|
|
78
|
-
error(f"[AWS
|
|
78
|
+
error(f"[AWS MYSQL] query error: {e}, SQL: {sql} ,params: {params}")
|
|
79
79
|
raise e
|
|
@@ -7,6 +7,7 @@ from aws_advanced_python_wrapper.sql_alchemy_connection_provider import (
|
|
|
7
7
|
|
|
8
8
|
from cloudoll.orm.base import MeteBase, QueryTypes
|
|
9
9
|
from cloudoll.logging import info, error
|
|
10
|
+
from psycopg2.extras import RealDictCursor
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class AwsPostgres(MeteBase):
|
|
@@ -33,7 +34,7 @@ class AwsPostgres(MeteBase):
|
|
|
33
34
|
with AwsWrapperConnection.connect(
|
|
34
35
|
psycopg.Connection.connect, self._dsn, **self._params
|
|
35
36
|
) as conn:
|
|
36
|
-
with conn.cursor() as cursor:
|
|
37
|
+
with conn.cursor(cursor_factory=RealDictCursor) as cursor:
|
|
37
38
|
if (
|
|
38
39
|
query_type == QueryTypes.CREATEBATCH
|
|
39
40
|
or query_type == QueryTypes.UPDATEBATCH
|
|
@@ -44,25 +45,12 @@ class AwsPostgres(MeteBase):
|
|
|
44
45
|
|
|
45
46
|
result = None
|
|
46
47
|
|
|
47
|
-
if query_type == QueryTypes.ALL
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
query_type == QueryTypes.ONE and cursor.description is not None
|
|
54
|
-
):
|
|
55
|
-
columns = [desc[0] for desc in cursor.target_cursor.description]
|
|
56
|
-
row = cursor.fetchone()
|
|
57
|
-
result = dict(zip(columns, row)) if row else {}
|
|
58
|
-
return result
|
|
59
|
-
elif (
|
|
60
|
-
query_type == QueryTypes.MANY and cursor.description is not None
|
|
61
|
-
):
|
|
62
|
-
columns = [desc[0] for desc in cursor.target_cursor.description]
|
|
63
|
-
rows = cursor.fetchmany(size)
|
|
64
|
-
result = [dict(zip(columns, row)) for row in rows]
|
|
65
|
-
return result
|
|
48
|
+
if query_type == QueryTypes.ALL:
|
|
49
|
+
return cursor.fetchall()
|
|
50
|
+
elif query_type == QueryTypes.ONE:
|
|
51
|
+
return cursor.fetchone()
|
|
52
|
+
elif query_type == QueryTypes.MANY:
|
|
53
|
+
return cursor.fetchmany(size)
|
|
66
54
|
elif query_type == QueryTypes.COUNT:
|
|
67
55
|
result = cursor.fetchone()
|
|
68
56
|
count = 0
|
|
@@ -89,5 +77,5 @@ class AwsPostgres(MeteBase):
|
|
|
89
77
|
elif query_type == QueryTypes.DELETE:
|
|
90
78
|
return cursor.rowcount > 0
|
|
91
79
|
except Exception as e:
|
|
92
|
-
error(f"[AWS PG] query error: {e}, SQL: {sql}")
|
|
80
|
+
error(f"[AWS PG] query error: {e}, SQL: {sql} params: {params}")
|
|
93
81
|
raise e
|
|
@@ -238,7 +238,6 @@ class FieldBase(object):
|
|
|
238
238
|
|
|
239
239
|
def contains(self, args):
|
|
240
240
|
return Function(self, OP.CONTAINS, args)
|
|
241
|
-
# return AO(f"contains({self.full_name},?)", args)
|
|
242
241
|
|
|
243
242
|
def As(self, args):
|
|
244
243
|
return Expression(self, OP.AS, args)
|
|
@@ -351,7 +350,6 @@ class Function(FieldBase):
|
|
|
351
350
|
return f"{col_name} < NOW() - INTERVAL {self.rpt} SECOND", None
|
|
352
351
|
elif op == OP.CONTAINS:
|
|
353
352
|
return f"{col_name} LIKE CONCAT('%%',?,'%%')", [self.rpt]
|
|
354
|
-
# return f"CONTAINS({col_name},?)", [self.rpt]
|
|
355
353
|
elif op == OP.JSON_CONTAINS_OBJECT:
|
|
356
354
|
_k, _v = self.rpt
|
|
357
355
|
key = _k.full_name if isinstance(_k, Field) else f"'{_k}'"
|
|
@@ -465,8 +463,13 @@ class Expression(FieldBase):
|
|
|
465
463
|
elif self.op == OP.AS:
|
|
466
464
|
q.append(r)
|
|
467
465
|
elif r is not None:
|
|
468
|
-
|
|
469
|
-
|
|
466
|
+
if isinstance(r, (list, tuple)):
|
|
467
|
+
# fix op is `in``
|
|
468
|
+
q.append(f"({','.join(['?'] * len(r))})")
|
|
469
|
+
p.extend(r)
|
|
470
|
+
else:
|
|
471
|
+
q.append("?")
|
|
472
|
+
p.append(r)
|
|
470
473
|
if not is_fun and not isinstance(l, Field):
|
|
471
474
|
q.append(")")
|
|
472
475
|
q = [str(num) for num in q]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import aiopg
|
|
2
|
+
from psycopg2.extras import RealDictCursor
|
|
2
3
|
from cloudoll.logging import error
|
|
3
4
|
from cloudoll.orm.base import MeteBase, QueryTypes
|
|
4
5
|
from cloudoll.logging import info, error
|
|
@@ -35,7 +36,7 @@ class Postgres(MeteBase):
|
|
|
35
36
|
if conn.echo:
|
|
36
37
|
info("sql: %s ,%s", sql, params)
|
|
37
38
|
|
|
38
|
-
async with conn.cursor() as cursor:
|
|
39
|
+
async with conn.cursor(cursor_factory=RealDictCursor) as cursor:
|
|
39
40
|
# current_cursor = getattr(cursor, 'lastrowid', None)
|
|
40
41
|
if (
|
|
41
42
|
query_type == QueryTypes.CREATEBATCH
|
|
@@ -48,21 +49,12 @@ class Postgres(MeteBase):
|
|
|
48
49
|
# await conn.commit()
|
|
49
50
|
result = None
|
|
50
51
|
|
|
51
|
-
if query_type == QueryTypes.ALL
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
columns = [desc[0] for desc in cursor.description]
|
|
58
|
-
row = await cursor.fetchone()
|
|
59
|
-
result = dict(zip(columns, row)) if row else {}
|
|
60
|
-
return result
|
|
61
|
-
elif query_type == QueryTypes.MANY and cursor.description is not None:
|
|
62
|
-
columns = [desc[0] for desc in cursor.description]
|
|
63
|
-
rows = await cursor.fetchmany(size)
|
|
64
|
-
result = [dict(zip(columns, row)) for row in rows]
|
|
65
|
-
return result
|
|
52
|
+
if query_type == QueryTypes.ALL:
|
|
53
|
+
return await cursor.fetchall()
|
|
54
|
+
elif query_type == QueryTypes.ONE:
|
|
55
|
+
return await cursor.fetchone()
|
|
56
|
+
elif query_type == QueryTypes.MANY:
|
|
57
|
+
return await cursor.fetchmany(size)
|
|
66
58
|
elif query_type == QueryTypes.COUNT:
|
|
67
59
|
result = await cursor.fetchone()
|
|
68
60
|
count = 0
|
|
@@ -63,7 +63,7 @@ class C(Model):
|
|
|
63
63
|
is_timeout = models.BooleanField(default="true", not_null=True)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
def test_query():
|
|
67
67
|
sql, arg = (
|
|
68
68
|
B.use()
|
|
69
69
|
.select(
|
|
@@ -87,3 +87,18 @@ if __name__ == "__main__":
|
|
|
87
87
|
)
|
|
88
88
|
# sql = B()._exchange_sql(sql)
|
|
89
89
|
print(sql, arg)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_a():
|
|
93
|
+
role_id = ("5", 4, 7, 6)
|
|
94
|
+
sql, arg = (
|
|
95
|
+
B.use()
|
|
96
|
+
.join(A, A.id == B.id)
|
|
97
|
+
.where(B.proxy_order_no.In(role_id), B.channel_type == 0, A.id.In(role_id))
|
|
98
|
+
.test()
|
|
99
|
+
)
|
|
100
|
+
print(sql, tuple(arg))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
test_a()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudoll
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.9
|
|
4
4
|
Summary: Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use.
|
|
5
5
|
Home-page: https://github.com/smallerqiu/cloudoll-py
|
|
6
6
|
Author: Qiu
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cloudoll"
|
|
7
|
-
version = "3.0.
|
|
7
|
+
version = "3.0.9"
|
|
8
8
|
description = "Assist in quickly creating distributable microservices based on aiohttp, with a focus on simplicity and ease of use."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Qiu", email = "smallerqiu@gmail.com"},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "3.0.7"
|
|
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
|