python-mapper 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl

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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-mapper
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: PostgreSQL XML mapper with asyncpg pooling and implicit transactions
5
5
  Author: z77777777777
6
6
  License-Expression: MIT
@@ -29,20 +29,55 @@ Dynamic: license-file
29
29
 
30
30
  # python-mapper
31
31
 
32
- [English](README.md) · [简体中文](README.zh-CN.md)
32
+ [English](https://github.com/z77777777777/python-mapper/blob/main/README.md) ·
33
+ [简体中文](https://github.com/z77777777777/python-mapper/blob/main/README.zh-CN.md)
33
34
 
34
- PostgreSQL-first XML mapper runtime backed directly by asyncpg. The package is
35
- framework-neutral: it does not import FastAPI, a host application's settings,
36
- logging formatter, schema, or business models.
35
+ A lightweight asynchronous XML mapper for Python. It keeps SQL out of business code —
36
+ queries live in XML, Python keeps only the signature — so a service method reads as what
37
+ the business does, not as string assembly around a cursor.
38
+
39
+ PostgreSQL-first, backed directly by asyncpg. The package is framework-neutral: it does
40
+ not import FastAPI, a host application's settings, logging formatter, schema, or business
41
+ models.
37
42
 
38
43
  ## Installation
39
44
 
40
45
  ```bash
41
- pip install "git+https://github.com/z77777777777/python-mapper.git@v0.3.0"
46
+ pip install python-mapper
42
47
  ```
43
48
 
44
49
  Requires Python 3.12+. The only runtime dependencies are `asyncpg` and `Jinja2`.
45
50
 
51
+ ## Async only
52
+
53
+ Every execution path is asynchronous. Mapper calls, `query()` and `scalar()` return
54
+ coroutines, and `transactional()` raises `TypeError` at decoration time if handed a
55
+ synchronous function. This is not an omission — the driver underneath is asyncpg, which
56
+ has no synchronous API at all.
57
+
58
+ To use it from a synchronous framework (Flask, a classic Django view, a script), run one
59
+ long-lived event loop in a background thread and submit work to it:
60
+
61
+ ```python
62
+ import asyncio
63
+ import threading
64
+
65
+ loop = asyncio.new_event_loop()
66
+ threading.Thread(target=loop.run_forever, daemon=True).start()
67
+
68
+ # Open the pool once, on that loop.
69
+ asyncio.run_coroutine_threadsafe(open_database(...), loop).result()
70
+
71
+ # Then, from synchronous code:
72
+ rows = asyncio.run_coroutine_threadsafe(
73
+ OrdersMapper.find(order_id=1), loop,
74
+ ).result()
75
+ ```
76
+
77
+ Do **not** wrap individual calls in `asyncio.run()`. That builds a fresh event loop every
78
+ time, while an asyncpg pool stays bound to the loop that created it — you would either hit
79
+ "attached to a different loop" errors or rebuild the pool on every request.
80
+
46
81
  ## Package layout
47
82
 
48
83
  - `database.py`: asyncpg pool configuration, startup, shutdown, and connection checkout.
@@ -10,8 +10,8 @@ python_mapper/pagination.py,sha256=OhsViezQzb6TpJ1bc5Gx1cUZQLFKYUkJ6DL652qdxOw,7
10
10
  python_mapper/plugins.py,sha256=sMSyqPUaQiEf-qvCDUKHAJl-Hzpcw_sJ1BajYBOT36I,2636
11
11
  python_mapper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  python_mapper/runtime.py,sha256=1EqwgFglxOIHIyOf_R2_pPY7nF_28b_Skt0sPtYa1ng,40540
13
- python_mapper-0.3.0.dist-info/licenses/LICENSE,sha256=89AMHBodYQSUMhc1keoqcONt43U-ERdO9AChPNU4wKw,1069
14
- python_mapper-0.3.0.dist-info/METADATA,sha256=niPhqdYs2GbK0COkU0-ppvckXMxuKR3MnYGNGdYROOU,10821
15
- python_mapper-0.3.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
- python_mapper-0.3.0.dist-info/top_level.txt,sha256=DTSU9ONdLTaXBUGMukwt6GcO34cUY52kYD2giQ3B638,14
17
- python_mapper-0.3.0.dist-info/RECORD,,
13
+ python_mapper-0.3.1.dist-info/licenses/LICENSE,sha256=89AMHBodYQSUMhc1keoqcONt43U-ERdO9AChPNU4wKw,1069
14
+ python_mapper-0.3.1.dist-info/METADATA,sha256=GHNhrl4khCD01oZ-i4QUnWJ_MRpfg2chv7AJywASJgU,12201
15
+ python_mapper-0.3.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
+ python_mapper-0.3.1.dist-info/top_level.txt,sha256=DTSU9ONdLTaXBUGMukwt6GcO34cUY52kYD2giQ3B638,14
17
+ python_mapper-0.3.1.dist-info/RECORD,,