Skip to content

Commit 2b9f3f0

Browse files
committed
chore: config
1 parent e3ac46c commit 2b9f3f0

File tree

6 files changed

+53
-6
lines changed

6 files changed

+53
-6
lines changed

docs/pypi-package/pyside6/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
| https://zhuanlan.zhihu.com/p/133303836 | Nuitka 博客 |
1818
| https://github.com/flyfire/pyside6-examples | PySide6 示例代码(超多) |
1919
| https://github.com/muziing/PySide6-Code-Tutorial | PySide6 中文教程 |
20+
| https://www.pythonguis.com/ | PySide6 英文教程 |
2021
2122
-->

docs/python-core/collections/case-insensitive-dict.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ print(res.headers['Connection'])
1111
print(res.headers['connection'])
1212
```
1313

14-
这两个结果一致。下面我们通过魔术方法实现一个大小写不敏感的字典[^1]
14+
这两个结果一致。下面我们通过魔术方法实现一个大小写不敏感的字典,参考了网络上的其他方法[^1]
1515

1616
```python
1717
class CaseInsensitiveDict(dict):
@@ -38,4 +38,4 @@ class CaseInsensitiveDict(dict):
3838
return f"{type(self).__name__}({super().__repr__()})"
3939
```
4040

41-
[1]: <http://www.coolpython.net/informal_essay/20-03/ignore_case_dict.html>
41+
[1]: Python 创建一个大小写不敏感的字典,CoolPython,<http://www.coolpython.net/informal_essay/20-03/ignore_case_dict.html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 进制转换
2+
3+
[[TOC]]
4+
5+
## 1. 字符串转换
6+
7+
```python
8+
9+
```
10+
11+
## 2. 数组表示的任意进制
12+
13+
14+
15+
```python
16+
def convert_base(number: int, base: int = 10) -> list[int]:
17+
if number < 0 or base < 2:
18+
raise ValueError(
19+
'"number" must be positive and "base" must be greater than 1'
20+
)
21+
if number == 0 or base == 10:
22+
return [number]
23+
res = []
24+
while number != 0:
25+
number, mod = divmod(number, base)
26+
res.append(mod)
27+
res.reverse()
28+
return res
29+
30+
def from_list(l: list[int], base: int = 10) -> int:
31+
if base < 2:
32+
raise ValueError('"base" must be greater than 1')
33+
res = 0
34+
for x in l:
35+
res = res * base + x
36+
return res
37+
```
38+
39+

docs/python-core/collections/import-python-file-from-path.md

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
```python
66
import importlib.util
77

8-
98
def load_file(path: str):
109
spec = importlib.util.spec_from_file_location('module_name', path)
1110
modulevar = importlib.util.module_from_spec(spec)

docs/python-core/errors/sqlalchemy-lost-connection.md

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ SQLAlchemy 会报错:
8282

8383
## 2. 解决方案
8484

85+
我们先学习一下 SQLAlchemy 的连接池参数。
86+
- `pool_size`:设置连接池中,保持的连接数。初始化时并不产生连接。
87+
- `max_overflow`:当连接池里的连接数已达到 `pool_size` 时,且都被使用时。又要求从连接池里获取连接时,`max_overflow` 就是允许再新建的连接数。
88+
- `pool_timeout`:从连接池里获取连接,如果此时无空闲的连接。且连接数已经到达了 `pool_size+max_overflow`。此时获取连接的进程会等待 `pool_timeout` 秒。如果超过这个时间,还没有获得将会抛出异常,默认为 30 秒。
89+
- `pool_recycle`:数据库连接的生存时间。一个连接当连接空闲 `pool_recycle` 秒后,会被重置。默认为 -1,即永久可用。
90+
91+
`pool_recycle` 设置为 -1 时,也就是连接池不会主动丢弃这个连接。但是有可能数据库设置了连接超时时间。例如 MySQL,设置的有 `wait_timeout` 默认为 28800。当连接空闲 8 小时时会自动断开。
92+
8593
### 2.1 不使用连接池
8694

8795
在创建引擎时,设置 `poolclass=NullPool`,不使用连接池。

pnpm-lock.yaml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)