Skip to content

Commit 3823802

Browse files
authored
add disconnect handling note when using sqlalchemy against TiDB Serverless (#17285) (#17289)
1 parent ab537d4 commit 3823802

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

develop/dev-guide-sample-application-python-sqlalchemy.md

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ SQLAlchemy 是一个支持多种数据库的 ORM 库。它是对数据库的高
6060

6161
<div label="TiDB Serverless">
6262

63+
> **注意:**
64+
>
65+
> TiDB Serverless 集群目前存在一个限制:如果 5 分钟内没有活跃连接,集群将会自动关闭,这会导致所有连接中断。因此,当使用 SQLAlchemy 连接到 TiDB Serverless 集群时,从连接池中获取的连接可能会遇到 `OperationalError` 报错,例如 `Lost connection to MySQL server during query``MySQL Connection not available`。为了避免该错误,可将 `pool_recycle` 参数设置为 `300`。更多信息,请参阅 SQLAlchemy 文档 [Dealing with Disconnects](https://docs.sqlalchemy.org/en/20/core/pooling.html#dealing-with-disconnects)
66+
6367
1. 在 TiDB Cloud 的 [**Clusters**](https://tidbcloud.com/console/clusters) 页面中,选择你的 TiDB Serverless 集群,进入集群的 **Overview** 页面。
6468

6569
2. 点击右上角的 **Connect** 按钮,将会弹出连接对话框。

0 commit comments

Comments
 (0)