BatisX 2.2.4__tar.gz → 2.2.5__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.
@@ -1,16 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: BatisX
3
- Version: 2.2.4
3
+ Version: 2.2.5
4
4
  Summary: A easy thread safe sql executor for Python like MyBatis with connection pool. It helps you automatically manage database connections and transactions. Support MySQL, PostgreSQL, SQLite etc.
5
5
  Home-page: https://gitee.com/summry/batisx
6
6
  Author: summy
7
7
  Author-email: xiazhongbiao@126.com
8
- License: UNKNOWN
9
8
  Keywords: sql,MySQL,PostgreSQL,MyBatis,python
10
- Platform: UNKNOWN
11
9
  Requires-Python: >=3.5
12
10
  Description-Content-Type: text/markdown
13
11
  License-File: LICENSE
12
+ Requires-Dist: mysqlx>=2.3.1
14
13
 
15
14
  Mapper file
16
15
  '''''''''''
@@ -177,11 +176,10 @@ Transaction
177
176
  insert_func(....)
178
177
  update_func(....)
179
178
 
179
+ If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
180
180
 
181
- If you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx
182
-
183
- If you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx
184
-
185
- If you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx
181
+ If you want to operate MySQL database, may be you need MySQLX: https://pypi.org/project/mysqlx
186
182
 
183
+ If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
187
184
 
185
+ If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
@@ -0,0 +1 @@
1
+ mysqlx>=2.3.1
@@ -1,16 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: BatisX
3
- Version: 2.2.4
3
+ Version: 2.2.5
4
4
  Summary: A easy thread safe sql executor for Python like MyBatis with connection pool. It helps you automatically manage database connections and transactions. Support MySQL, PostgreSQL, SQLite etc.
5
5
  Home-page: https://gitee.com/summry/batisx
6
6
  Author: summy
7
7
  Author-email: xiazhongbiao@126.com
8
- License: UNKNOWN
9
8
  Keywords: sql,MySQL,PostgreSQL,MyBatis,python
10
- Platform: UNKNOWN
11
9
  Requires-Python: >=3.5
12
10
  Description-Content-Type: text/markdown
13
11
  License-File: LICENSE
12
+ Requires-Dist: mysqlx>=2.3.1
14
13
 
15
14
  Mapper file
16
15
  '''''''''''
@@ -177,11 +176,10 @@ Transaction
177
176
  insert_func(....)
178
177
  update_func(....)
179
178
 
179
+ If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
180
180
 
181
- If you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx
182
-
183
- If you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx
184
-
185
- If you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx
181
+ If you want to operate MySQL database, may be you need MySQLX: https://pypi.org/project/mysqlx
186
182
 
183
+ If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
187
184
 
185
+ If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
@@ -163,9 +163,10 @@ Transaction
163
163
  insert_func(....)
164
164
  update_func(....)
165
165
 
166
+ If you want to use ORM, may be you need SQLORMX: https://pypi.org/project/sqlormx
166
167
 
167
- If you want to operate MySQL database, may be you need MySqlx: https://pypi.org/project/mysqlx
168
+ If you want to operate MySQL database, may be you need MySQLX: https://pypi.org/project/mysqlx
168
169
 
169
- If you want to operate PostgreSQL database, may be you need MySqlx: https://pypi.org/project/pgsqlx
170
+ If you want to operate PostgreSQL database, may be you need PgSQLX: https://pypi.org/project/pgsqlx
170
171
 
171
- If you just wanted a simple sql executor, may be you need sqlx-exec: https://pypi.org/project/sqlexecx
172
+ If you just wanted a simple sql executor, may be you need SQLExecX: https://pypi.org/project/sqlexecx
@@ -0,0 +1,71 @@
1
+ """
2
+ 可以设置`SQL_CACHE_SIZE`环境变量来设置缓存大小,默认是128。
3
+ linux or macos:
4
+ export SQL_CACHE_SIZE=256
5
+ windows:
6
+ set SQL_CACHE_SIZE=256
7
+
8
+ 可以设置`LRU_CACHE_SIZE`环境变量来设置缓存大小,默认是64。
9
+ linux or macos:
10
+ export LRU_CACHE_SIZE=128
11
+ windows:
12
+ set LRU_CACHE_SIZE=128
13
+ """
14
+
15
+ from mysqlx import (
16
+ conn,
17
+ trans,
18
+ get_connection,
19
+ close,
20
+ Driver,
21
+ Dialect,
22
+ Engine
23
+ )
24
+ from .sql_mapper import sql, mapper
25
+
26
+
27
+ def init_db(*args, **kwargs) -> Engine:
28
+ """
29
+ Compliant with the Python DB API 2.0 (PEP-249).
30
+
31
+ Addition parameters:
32
+ - mapper_path: str, path of mapper files
33
+ - driver=None: str|Driver, 'psycopg2' or 'pymysql' or 'mysql.connector' or 'sqlite3' or 'turso'
34
+ - pool_size=0: int, default 0, size of connection pool
35
+ - show_sql=False: bool, if True, print sql
36
+ - debug=False: bool, if True, print debug context
37
+
38
+ Other parameters of connection pool refer to DBUtils: https://webwareforpython.github.io/DBUtils/main.html#pooleddb-pooled-db
39
+
40
+ Examples
41
+ --------
42
+ >>> from mysqlx import db, trans, init_db
43
+ >>> init_db('db.sqlite3', mapper_path='./mapper', driver='sqlite3', debug=True)
44
+ Engine.SQLITE
45
+ >>> init_db("postgres://user:password@127.0.0.1:5432/testdb", driver='psycopg2', pool_size=5, debug=True)
46
+ Engine.POSTGRESQL
47
+ >>> init_db(user='root', password='xxx', host='127.0.0.1', port=3306, database='testdb', driver='pymysql', mapper_path='./mapper')
48
+ Engine.MYSQL
49
+ """
50
+ from mysqlx.sql_holder import load_mapper
51
+
52
+ mapper_path = kwargs.pop(InitArgs.MAPPER_PATH) if InitArgs.MAPPER_PATH in kwargs else None
53
+ engine = _init(*args, **kwargs)
54
+ if mapper_path:
55
+ load_mapper(mapper_path)
56
+ return engine
57
+
58
+
59
+ __all__ = [
60
+ 'conn',
61
+ 'trans',
62
+ 'get_connection',
63
+ 'close',
64
+ 'Driver',
65
+ 'Dialect',
66
+ 'Engine',
67
+ 'init_db',
68
+ 'sql',
69
+ 'mapper'
70
+ ]
71
+
@@ -1,3 +1,4 @@
1
+ from typing import Any
1
2
  from mysqlx import sql_support
2
3
  # Don't remove. Import for not repetitive implementation
3
4
  from sqlexecx import save_select_key, do_save_sql_select_key
@@ -6,7 +7,7 @@ from mysqlx.db import insert, save, execute, batch_insert, batch_execute, get, q
6
7
  do_save_sql, drop_table, truncate_table, sql, table, page
7
8
 
8
9
 
9
- def save_sql(sql: str, *args, **kwargs):
10
+ def save_sql(sql: str, *args, **kwargs) -> Any:
10
11
  """
11
12
  Insert data into table, return primary key.
12
13
 
@@ -25,7 +26,7 @@ def save_sql(sql: str, *args, **kwargs):
25
26
  return do_save_sql(sql, *args)
26
27
 
27
28
 
28
- def save_sql_select_key(select_key: str, sql: str, *args, **kwargs):
29
+ def save_sql_select_key(select_key: str, sql: str, *args, **kwargs) -> Any:
29
30
  """
30
31
  Insert data into table, return primary key.
31
32
 
@@ -1,3 +1,4 @@
1
+ from typing import Any
1
2
  from mysqlx import sql_holder as holder
2
3
  from mysqlx.dbx import batch_execute, execute, get, query, query_one, select, select_one, select_page, query_page, sql, page
3
4
 
@@ -5,7 +6,7 @@ from . import db
5
6
  from .log_support import logger, sql_id_log, page_sql_id_log, sql_id_select_key_log
6
7
 
7
8
 
8
- def save(sql_id: str, *args, **kwargs):
9
+ def save(sql_id: str, *args, **kwargs) -> Any:
9
10
  """
10
11
  Execute insert SQL, return primary key.
11
12
  :return: Primary key
@@ -19,7 +20,7 @@ def save(sql_id: str, *args, **kwargs):
19
20
  return db.do_save_sql(sql, *args)
20
21
 
21
22
 
22
- def save_select_key(select_key, sql_id: str, *args, **kwargs):
23
+ def save_select_key(select_key, sql_id: str, *args, **kwargs) -> Any:
23
24
  """
24
25
  Execute insert SQL, return primary key.
25
26
  :return: Primary key
@@ -1,3 +1,4 @@
1
+ from typing import Any
1
2
  from . import dbx
2
3
  from mysqlx.sql_id_exec import SqlExec as _SqlExec
3
4
  from sqlexecx.page_exec import PageExec
@@ -5,7 +6,7 @@ from sqlexecx.page_exec import PageExec
5
6
 
6
7
  class SqlExec(_SqlExec):
7
8
 
8
- def save_select_key(self, select_key: str, *args, **kwargs):
9
+ def save_select_key(self, select_key: str, *args, **kwargs) -> Any:
9
10
  """
10
11
  Insert data into table, return primary key.
11
12
 
@@ -16,10 +17,10 @@ class SqlExec(_SqlExec):
16
17
  return self.exec.save_select_key(select_key, self.sql, *args, **kwargs)
17
18
 
18
19
 
19
- def sql(sql: str) :
20
+ def sql(sql: str) -> SqlExec:
20
21
  assert sql, "Parameter 'sql' must not be none"
21
22
  return SqlExec(dbx, sql)
22
23
 
23
24
 
24
- def page(page_num: int, page_size: int) :
25
+ def page(page_num: int, page_size: int) -> PageExec:
25
26
  return PageExec(dbx, page_num, page_size)
@@ -3,7 +3,7 @@ from sqlexecx.sql_exec import SqlExec
3
3
  from sqlexecx.page_exec import PageExec
4
4
 
5
5
 
6
- def sql(sql: str):
6
+ def sql(sql: str) -> SqlExec:
7
7
  """
8
8
  Get a SqlExec instance
9
9
 
@@ -16,7 +16,7 @@ def sql(sql: str):
16
16
  return SqlExec(db, sql)
17
17
 
18
18
 
19
- def page(page_num: int, page_size: int):
19
+ def page(page_num: int, page_size: int) -> PageExec:
20
20
  """
21
21
  Get a PageExec instance
22
22
 
@@ -18,9 +18,9 @@ setup(
18
18
  long_description=long_description,
19
19
  long_description_content_type='text/markdown',
20
20
  install_requires=[
21
- 'mysqlx>=2.2.8',
21
+ 'mysqlx>=2.3.1',
22
22
  ],
23
- version='2.2.4',
23
+ version='2.2.5',
24
24
  url='https://gitee.com/summry/batisx',
25
25
  author='summy',
26
26
  author_email='xiazhongbiao@126.com',
@@ -1 +0,0 @@
1
- mysqlx>=2.2.8
@@ -1,11 +0,0 @@
1
- from mysqlx import (
2
- conn,
3
- trans,
4
- get_connection,
5
- close,
6
- Driver,
7
- Dialect,
8
- init_db
9
- )
10
- from .sql_mapper import sql, mapper
11
-
File without changes
File without changes
File without changes
File without changes