Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 868132b

Browse files
kulameigengmei
andauthored
option pool_recycle (#233)
* option pool_recycle * #233 allow setting pool_recycle * #233 typo error * #233 typo error * #233 reformat code Co-authored-by: kula <[email protected]>
1 parent 0af2db8 commit 868132b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode/
12
*.pyc
23
test.db
34
.coverage

databases/backends/mysql.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ def _get_connection_kwargs(self) -> dict:
3232
kwargs = {}
3333
min_size = url_options.get("min_size")
3434
max_size = url_options.get("max_size")
35+
pool_recycle = url_options.get("pool_recycle")
3536
ssl = url_options.get("ssl")
3637

3738
if min_size is not None:
3839
kwargs["minsize"] = int(min_size)
3940
if max_size is not None:
4041
kwargs["maxsize"] = int(max_size)
42+
if pool_recycle is not None:
43+
kwargs["pool_recycle"] = int(pool_recycle)
4144
if ssl is not None:
4245
kwargs["ssl"] = {"true": True, "false": False}[ssl.lower()]
4346

tests/test_connection_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def test_mysql_explicit_ssl():
6767
assert kwargs == {"ssl": True}
6868

6969

70+
def test_mysql_pool_recycle():
71+
backend = MySQLBackend("mysql://localhost/database?pool_recycle=20")
72+
kwargs = backend._get_connection_kwargs()
73+
assert kwargs == {"pool_recycle": 20}
74+
75+
7076
def test_aiopg_pool_size():
7177
backend = AiopgBackend(
7278
"postgresql+aiopg://localhost/database?min_size=1&max_size=20"

0 commit comments

Comments
 (0)