xbot.plugins.pgsql 0.1.0__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.
- xbot_plugins_pgsql-0.1.0/LICENSE +24 -0
- xbot_plugins_pgsql-0.1.0/PKG-INFO +134 -0
- xbot_plugins_pgsql-0.1.0/README.md +54 -0
- xbot_plugins_pgsql-0.1.0/README.zh.md +54 -0
- xbot_plugins_pgsql-0.1.0/docs/superpowers/plans/2026-07-24-pgsql-library.md +1871 -0
- xbot_plugins_pgsql-0.1.0/docs/superpowers/specs/2026-07-24-pgsql-library-design.md +433 -0
- xbot_plugins_pgsql-0.1.0/pyproject.toml +65 -0
- xbot_plugins_pgsql-0.1.0/setup.cfg +4 -0
- xbot_plugins_pgsql-0.1.0/setup.py +26 -0
- xbot_plugins_pgsql-0.1.0/tests/__init__.py +0 -0
- xbot_plugins_pgsql-0.1.0/tests/run.py +36 -0
- xbot_plugins_pgsql-0.1.0/tests/test_pgsql.py +254 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/__init__.py +17 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/codes.py +363 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/errors.py +44 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/pgsql.py +213 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/py.typed +0 -0
- xbot_plugins_pgsql-0.1.0/xbot/plugins/pgsql/version.py +5 -0
- xbot_plugins_pgsql-0.1.0/xbot.plugins.pgsql.egg-info/PKG-INFO +134 -0
- xbot_plugins_pgsql-0.1.0/xbot.plugins.pgsql.egg-info/SOURCES.txt +21 -0
- xbot_plugins_pgsql-0.1.0/xbot.plugins.pgsql.egg-info/dependency_links.txt +1 -0
- xbot_plugins_pgsql-0.1.0/xbot.plugins.pgsql.egg-info/requires.txt +7 -0
- xbot_plugins_pgsql-0.1.0/xbot.plugins.pgsql.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2023, zhaowcheng <zhaowcheng@163.com>
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xbot.plugins.pgsql
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: PostgreSQL library for xbot.framework
|
|
5
|
+
Author-email: zhaowcheng <zhaowcheng@163.com>
|
|
6
|
+
License-Expression: BSD-2-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/zhaowcheng/xbot.plugins.pgsql
|
|
8
|
+
Project-URL: Issues, https://github.com/zhaowcheng/xbot.plugins.pgsql/issues
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: xbot.framework>=0.5.1
|
|
19
|
+
Requires-Dist: psycopg[binary]<4,>=3
|
|
20
|
+
Requires-Dist: cli_helpers
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: build; extra == "dev"
|
|
23
|
+
Requires-Dist: mypy; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<br>English | <a href="README.zh.md">中文</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# xbot.plugins.pgsql
|
|
33
|
+
|
|
34
|
+
PostgreSQL library for xbot.framework.
|
|
35
|
+
|
|
36
|
+
## Introduction
|
|
37
|
+
|
|
38
|
+
A synchronous PostgreSQL client library for [xbot.framework](https://pypi.org/project/xbot.framework/), built on Psycopg 3. It provides a thin connection wrapper with SQLSTATE-based expectation checking, psql-style result rendering, and explicit transaction support.
|
|
39
|
+
|
|
40
|
+
Python >= 3.10, PostgreSQL >= 14. For full API documentation, refer to the docstrings in each module.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install xbot.plugins.pgsql
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Getting Started
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from xbot.plugins.pgsql import PGCodes, PGSQLConnection
|
|
52
|
+
|
|
53
|
+
db = PGSQLConnection()
|
|
54
|
+
db.connect(
|
|
55
|
+
host="127.0.0.1",
|
|
56
|
+
user="postgres",
|
|
57
|
+
password="secret",
|
|
58
|
+
database="postgres",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
result = db.exec(
|
|
62
|
+
"SELECT 1::integer AS id, 'alice'::text AS name",
|
|
63
|
+
)
|
|
64
|
+
print(result)
|
|
65
|
+
print(result.header)
|
|
66
|
+
print(result.rc)
|
|
67
|
+
print(result.cmd)
|
|
68
|
+
|
|
69
|
+
missing = db.exec(
|
|
70
|
+
"SELECT * FROM missing_table",
|
|
71
|
+
expect=PGCodes.UNDEFINED_TABLE,
|
|
72
|
+
)
|
|
73
|
+
assert missing.rc == "42P01"
|
|
74
|
+
|
|
75
|
+
with db.transaction():
|
|
76
|
+
db.exec("INSERT INTO accounts(id, balance) VALUES (1, 100)")
|
|
77
|
+
|
|
78
|
+
db.disconnect()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<p align="center">
|
|
82
|
+
<br>中文 | <a href="README.md">English</a>
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
# xbot.plugins.pgsql
|
|
88
|
+
|
|
89
|
+
xbot.framework 的 PostgreSQL 客户端库。
|
|
90
|
+
|
|
91
|
+
## 简介
|
|
92
|
+
|
|
93
|
+
基于 Psycopg 3 的同步 PostgreSQL 客户端库,面向 [xbot.framework](https://pypi.org/project/xbot.framework/)。提供薄封装连接,支持基于 SQLSTATE 的预期检查、psql 风格结果渲染和显式事务。
|
|
94
|
+
|
|
95
|
+
Python >= 3.10,PostgreSQL >= 14。完整 API 文档请参阅各模块的 docstring。
|
|
96
|
+
|
|
97
|
+
## 安装
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install xbot.plugins.pgsql
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 入门
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from xbot.plugins.pgsql import PGCodes, PGSQLConnection
|
|
107
|
+
|
|
108
|
+
db = PGSQLConnection()
|
|
109
|
+
db.connect(
|
|
110
|
+
host="127.0.0.1",
|
|
111
|
+
user="postgres",
|
|
112
|
+
password="secret",
|
|
113
|
+
database="postgres",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
result = db.exec(
|
|
117
|
+
"SELECT 1::integer AS id, 'alice'::text AS name",
|
|
118
|
+
)
|
|
119
|
+
print(result)
|
|
120
|
+
print(result.header)
|
|
121
|
+
print(result.rc)
|
|
122
|
+
print(result.cmd)
|
|
123
|
+
|
|
124
|
+
missing = db.exec(
|
|
125
|
+
"SELECT * FROM missing_table",
|
|
126
|
+
expect=PGCodes.UNDEFINED_TABLE,
|
|
127
|
+
)
|
|
128
|
+
assert missing.rc == "42P01"
|
|
129
|
+
|
|
130
|
+
with db.transaction():
|
|
131
|
+
db.exec("INSERT INTO accounts(id, balance) VALUES (1, 100)")
|
|
132
|
+
|
|
133
|
+
db.disconnect()
|
|
134
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<br>English | <a href="README.zh.md">中文</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# xbot.plugins.pgsql
|
|
8
|
+
|
|
9
|
+
PostgreSQL library for xbot.framework.
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
A synchronous PostgreSQL client library for [xbot.framework](https://pypi.org/project/xbot.framework/), built on Psycopg 3. It provides a thin connection wrapper with SQLSTATE-based expectation checking, psql-style result rendering, and explicit transaction support.
|
|
14
|
+
|
|
15
|
+
Python >= 3.10, PostgreSQL >= 14. For full API documentation, refer to the docstrings in each module.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install xbot.plugins.pgsql
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Getting Started
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from xbot.plugins.pgsql import PGCodes, PGSQLConnection
|
|
27
|
+
|
|
28
|
+
db = PGSQLConnection()
|
|
29
|
+
db.connect(
|
|
30
|
+
host="127.0.0.1",
|
|
31
|
+
user="postgres",
|
|
32
|
+
password="secret",
|
|
33
|
+
database="postgres",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
result = db.exec(
|
|
37
|
+
"SELECT 1::integer AS id, 'alice'::text AS name",
|
|
38
|
+
)
|
|
39
|
+
print(result)
|
|
40
|
+
print(result.header)
|
|
41
|
+
print(result.rc)
|
|
42
|
+
print(result.cmd)
|
|
43
|
+
|
|
44
|
+
missing = db.exec(
|
|
45
|
+
"SELECT * FROM missing_table",
|
|
46
|
+
expect=PGCodes.UNDEFINED_TABLE,
|
|
47
|
+
)
|
|
48
|
+
assert missing.rc == "42P01"
|
|
49
|
+
|
|
50
|
+
with db.transaction():
|
|
51
|
+
db.exec("INSERT INTO accounts(id, balance) VALUES (1, 100)")
|
|
52
|
+
|
|
53
|
+
db.disconnect()
|
|
54
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<br>中文 | <a href="README.md">English</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# xbot.plugins.pgsql
|
|
8
|
+
|
|
9
|
+
xbot.framework 的 PostgreSQL 客户端库。
|
|
10
|
+
|
|
11
|
+
## 简介
|
|
12
|
+
|
|
13
|
+
基于 Psycopg 3 的同步 PostgreSQL 客户端库,面向 [xbot.framework](https://pypi.org/project/xbot.framework/)。提供薄封装连接,支持基于 SQLSTATE 的预期检查、psql 风格结果渲染和显式事务。
|
|
14
|
+
|
|
15
|
+
Python >= 3.10,PostgreSQL >= 14。完整 API 文档请参阅各模块的 docstring。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install xbot.plugins.pgsql
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 入门
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from xbot.plugins.pgsql import PGCodes, PGSQLConnection
|
|
27
|
+
|
|
28
|
+
db = PGSQLConnection()
|
|
29
|
+
db.connect(
|
|
30
|
+
host="127.0.0.1",
|
|
31
|
+
user="postgres",
|
|
32
|
+
password="secret",
|
|
33
|
+
database="postgres",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
result = db.exec(
|
|
37
|
+
"SELECT 1::integer AS id, 'alice'::text AS name",
|
|
38
|
+
)
|
|
39
|
+
print(result)
|
|
40
|
+
print(result.header)
|
|
41
|
+
print(result.rc)
|
|
42
|
+
print(result.cmd)
|
|
43
|
+
|
|
44
|
+
missing = db.exec(
|
|
45
|
+
"SELECT * FROM missing_table",
|
|
46
|
+
expect=PGCodes.UNDEFINED_TABLE,
|
|
47
|
+
)
|
|
48
|
+
assert missing.rc == "42P01"
|
|
49
|
+
|
|
50
|
+
with db.transaction():
|
|
51
|
+
db.exec("INSERT INTO accounts(id, balance) VALUES (1, 100)")
|
|
52
|
+
|
|
53
|
+
db.disconnect()
|
|
54
|
+
```
|