MySQLX 2.2.7__tar.gz → 2.2.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.
- {MySQLX-2.2.7 → MySQLX-2.2.9/MySQLX.egg-info}/PKG-INFO +6 -2
- MySQLX-2.2.9/MySQLX.egg-info/requires.txt +2 -0
- {MySQLX-2.2.7/MySQLX.egg-info → MySQLX-2.2.9}/PKG-INFO +6 -2
- {MySQLX-2.2.7 → MySQLX-2.2.9}/README.rst +5 -1
- MySQLX-2.2.9/mysqlx/sql_id_exec.py +42 -0
- MySQLX-2.2.9/mysqlx/sql_page_exec.py +30 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/sql_support.py +6 -2
- {MySQLX-2.2.7 → MySQLX-2.2.9}/setup.py +2 -2
- MySQLX-2.2.7/MySQLX.egg-info/requires.txt +0 -2
- MySQLX-2.2.7/mysqlx/sql_id_exec.py +0 -25
- MySQLX-2.2.7/mysqlx/sql_page_exec.py +0 -12
- {MySQLX-2.2.7 → MySQLX-2.2.9}/LICENSE +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/MySQLX.egg-info/SOURCES.txt +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/MySQLX.egg-info/dependency_links.txt +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/MySQLX.egg-info/not-zip-safe +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/MySQLX.egg-info/top_level.txt +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/__init__.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/constant.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/db.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/dbx.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/log_support.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/sql_holder.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/sql_mapper.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/mysqlx/support.py +0 -0
- {MySQLX-2.2.7 → MySQLX-2.2.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: MySQLX
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.9
|
|
4
4
|
Summary: A thread safe sql executor for MySQL like MyBatis with connection pool. It helps you automatically manage database connections and transactions.
|
|
5
5
|
Home-page: https://gitee.com/summry/mysqlx
|
|
6
6
|
Author: summy
|
|
@@ -134,6 +134,10 @@ Usage Sample
|
|
|
134
134
|
# result:
|
|
135
135
|
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
136
136
|
|
|
137
|
+
users = db.table('user').columns('id, name, age').where(name__eq='zhangsan').query()
|
|
138
|
+
# result:
|
|
139
|
+
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
140
|
+
|
|
137
141
|
users = db.select('select id, name, age from user')
|
|
138
142
|
# result:
|
|
139
143
|
# (3, 'zhangsan', 15)
|
|
@@ -168,7 +172,7 @@ Transaction
|
|
|
168
172
|
|
|
169
173
|
If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
|
|
170
174
|
|
|
171
|
-
If you want to operate PostgreSQL database, may be you need
|
|
175
|
+
If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
|
|
172
176
|
|
|
173
177
|
If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
|
|
174
178
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: MySQLX
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.9
|
|
4
4
|
Summary: A thread safe sql executor for MySQL like MyBatis with connection pool. It helps you automatically manage database connections and transactions.
|
|
5
5
|
Home-page: https://gitee.com/summry/mysqlx
|
|
6
6
|
Author: summy
|
|
@@ -134,6 +134,10 @@ Usage Sample
|
|
|
134
134
|
# result:
|
|
135
135
|
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
136
136
|
|
|
137
|
+
users = db.table('user').columns('id, name, age').where(name__eq='zhangsan').query()
|
|
138
|
+
# result:
|
|
139
|
+
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
140
|
+
|
|
137
141
|
users = db.select('select id, name, age from user')
|
|
138
142
|
# result:
|
|
139
143
|
# (3, 'zhangsan', 15)
|
|
@@ -168,7 +172,7 @@ Transaction
|
|
|
168
172
|
|
|
169
173
|
If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
|
|
170
174
|
|
|
171
|
-
If you want to operate PostgreSQL database, may be you need
|
|
175
|
+
If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
|
|
172
176
|
|
|
173
177
|
If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
|
|
174
178
|
|
|
@@ -120,6 +120,10 @@ Usage Sample
|
|
|
120
120
|
# result:
|
|
121
121
|
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
122
122
|
|
|
123
|
+
users = db.table('user').columns('id, name, age').where(name__eq='zhangsan').query()
|
|
124
|
+
# result:
|
|
125
|
+
# [{'id': 3, 'name': 'zhangsan', 'age': 15}]
|
|
126
|
+
|
|
123
127
|
users = db.select('select id, name, age from user')
|
|
124
128
|
# result:
|
|
125
129
|
# (3, 'zhangsan', 15)
|
|
@@ -154,7 +158,7 @@ Transaction
|
|
|
154
158
|
|
|
155
159
|
If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
|
|
156
160
|
|
|
157
|
-
If you want to operate PostgreSQL database, may be you need
|
|
161
|
+
If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
|
|
158
162
|
|
|
159
163
|
If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
|
|
160
164
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from . import dbx
|
|
2
|
+
from sqlexecx.sql_exec import SqlExec
|
|
3
|
+
from sqlexecx.page_exec import PageExec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SqlIdExec(SqlExec):
|
|
7
|
+
|
|
8
|
+
def save(self, *args, **kwargs):
|
|
9
|
+
"""
|
|
10
|
+
Insert data into table, return primary key.
|
|
11
|
+
|
|
12
|
+
:param args:
|
|
13
|
+
:return: Primary key
|
|
14
|
+
"""
|
|
15
|
+
return self.exec.save(self.sql, *args, **kwargs)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def sql(sql_id: str):
|
|
19
|
+
"""
|
|
20
|
+
Get a SqlIdExec instance
|
|
21
|
+
|
|
22
|
+
Examples
|
|
23
|
+
--------
|
|
24
|
+
>>> from mysqlx import dbx
|
|
25
|
+
>>> dbx.sql('user.select_all')
|
|
26
|
+
SqlIdExec()
|
|
27
|
+
"""
|
|
28
|
+
assert sql_id, "Parameter 'sql_id' must not be none"
|
|
29
|
+
return SqlIdExec(dbx, sql_id)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def page(page_num: int, page_size: int):
|
|
33
|
+
"""
|
|
34
|
+
Get a PageExec instance
|
|
35
|
+
|
|
36
|
+
Examples
|
|
37
|
+
--------
|
|
38
|
+
>>> from mysqlx import dbx
|
|
39
|
+
>>> dbx.page(1, 10)
|
|
40
|
+
PageExec()
|
|
41
|
+
"""
|
|
42
|
+
return PageExec(dbx, page_num, page_size)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from . import db
|
|
2
|
+
from sqlexecx.sql_exec import SqlExec
|
|
3
|
+
from sqlexecx.page_exec import PageExec
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def sql(sql: str):
|
|
7
|
+
"""
|
|
8
|
+
Get a SqlExec instance
|
|
9
|
+
|
|
10
|
+
Examples
|
|
11
|
+
--------
|
|
12
|
+
>>> from mysqlx import db
|
|
13
|
+
>>> db.sql('SELECT id, name, age FROM person')
|
|
14
|
+
SqlExec()
|
|
15
|
+
"""
|
|
16
|
+
assert sql, "Parameter 'sql' must not be none"
|
|
17
|
+
return SqlExec(db, sql)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def page(page_num: int, page_size: int):
|
|
21
|
+
"""
|
|
22
|
+
Get a PageExec instance
|
|
23
|
+
|
|
24
|
+
Examples
|
|
25
|
+
--------
|
|
26
|
+
>>> from mysqlx import db
|
|
27
|
+
>>> db.page(1, 10)
|
|
28
|
+
PageExec()
|
|
29
|
+
"""
|
|
30
|
+
return PageExec(db, page_num, page_size)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import re
|
|
2
3
|
from jinja2 import Template
|
|
3
4
|
from functools import lru_cache
|
|
@@ -6,6 +7,9 @@ from .constant import DYNAMIC_REGEX, SQL_CACHE_SIZE
|
|
|
6
7
|
|
|
7
8
|
from sqlexecx.sql_support import get_named_sql_args, is_mapping, get_mapping_sql_args, try_mapping, get_batch_args
|
|
8
9
|
|
|
10
|
+
sql_cache_size = int(os.getenv('SQL_CACHE_SIZE', SQL_CACHE_SIZE))
|
|
11
|
+
print(f'======== SQL_CACHE_SIZE: {sql_cache_size}')
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
def simple_sql(sql: str, *args, **kwargs):
|
|
11
15
|
return get_named_sql_args(sql, **kwargs) if kwargs else (sql, args)
|
|
@@ -23,12 +27,12 @@ def get_page_start(page_num: int, page_size: int):
|
|
|
23
27
|
return (page_num - 1) * page_size
|
|
24
28
|
|
|
25
29
|
|
|
26
|
-
@lru_cache(maxsize=
|
|
30
|
+
@lru_cache(maxsize=sql_cache_size)
|
|
27
31
|
def is_dynamic_sql(sql: str):
|
|
28
32
|
return re.search(DYNAMIC_REGEX, sql) is not None
|
|
29
33
|
|
|
30
34
|
|
|
31
|
-
@lru_cache(maxsize=
|
|
35
|
+
@lru_cache(maxsize=sql_cache_size)
|
|
32
36
|
def _get_sql_type(sql: str):
|
|
33
37
|
"""
|
|
34
38
|
:return: 0: placeholder, 1: dynamic, 2: named mapping
|
|
@@ -19,9 +19,9 @@ setup(
|
|
|
19
19
|
long_description_content_type='text/markdown',
|
|
20
20
|
install_requires=[
|
|
21
21
|
'Jinja2>=2.7.0',
|
|
22
|
-
'sqlexecx>=2.1.
|
|
22
|
+
'sqlexecx>=2.1.9',
|
|
23
23
|
],
|
|
24
|
-
version='2.2.
|
|
24
|
+
version='2.2.9',
|
|
25
25
|
url='https://gitee.com/summry/mysqlx',
|
|
26
26
|
author='summy',
|
|
27
27
|
author_email='xiazhongbiao@126.com',
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from . import dbx
|
|
2
|
-
from sqlexecx.sql_exec import SqlExec as _SqlExec
|
|
3
|
-
from sqlexecx.page_exec import PageExec
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class SqlExec(_SqlExec):
|
|
7
|
-
|
|
8
|
-
def save(self, *args, **kwargs):
|
|
9
|
-
"""
|
|
10
|
-
Insert data into table, return primary key.
|
|
11
|
-
|
|
12
|
-
:param select_key: sql for select primary key
|
|
13
|
-
:param args:
|
|
14
|
-
:return: Primary key
|
|
15
|
-
"""
|
|
16
|
-
return self.exec.save(self.sql, *args, **kwargs)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def sql(sql: str) :
|
|
20
|
-
assert sql, "Parameter 'sql' must not be none"
|
|
21
|
-
return SqlExec(dbx, sql)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def page(page_num: int, page_size: int) :
|
|
25
|
-
return PageExec(dbx, page_num, page_size)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from . import db
|
|
2
|
-
from sqlexecx.sql_exec import SqlExec
|
|
3
|
-
from sqlexecx.page_exec import PageExec
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def sql(sql: str):
|
|
7
|
-
assert sql, "Parameter 'sql' must not be none"
|
|
8
|
-
return SqlExec(db, sql)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def page(page_num: int, page_size: int) :
|
|
12
|
-
return PageExec(db, page_num, page_size)
|
|
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
|