> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memorylake.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 更新数据库连接

> 修改数据库连接的名称、地址或凭据

```
PATCH /openapi/memorylake/api/v3/db-connections/{connectionId}
```

部分更新数据库连接。未传入的字段保持不变。

由于密码永远不会返回，只要修改任何凭据字段（`host`、`port`、`database` 或 `username`），就必须同时重新传入 `password`。

> [!NOTE]
>
> **所需权限：** `dbconn:modify`

### 路径参数

**connectionId** `string` *required*

数据库连接 ID

### 请求体

**name** `string`

显示名称

**description** `string`

自由格式的描述

**host** `string`

服务器主机名或地址

**port** `integer`

服务器端口，取值 1 到 65535

**database** `string`

要读取的数据库名

**username** `string`

用于认证的用户名

**password** `string`

用于认证的密码。任何接口都不会返回它。

```bash Rename theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/db-connections/dbconn-7c1e9a4b2d6f4a8e9b3c5d7f1a2b4c6d' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Sales warehouse (replica)"
  }'
```

```bash Rotate credentials theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/db-connections/dbconn-7c1e9a4b2d6f4a8e9b3c5d7f1a2b4c6d' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "username": "analytics_ro_2026",
    "password": "your-new-database-password"
  }'
```

### 响应

返回更新后的连接。

**data** `object`

**连接对象**

**id** `string`

数据库连接标识符，请把它当作不透明字符串处理。

**name** `string`

显示名称

**description** `string`

自由格式的描述

**host** `string`

服务器主机名或地址

**port** `integer`

服务器端口

**username** `string`

连接用于认证的用户名

**database** `string`

要读取的数据库名

**custom\_id** `string`

您为这个连接设置的自定义标识符（如果设置过）

**datasource\_count** `integer`

当前通过这个连接读取数据的数据源数量

**created\_at** `string`

创建时间戳

**updated\_at** `string`

最后更新时间戳

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "id": "dbconn-7c1e9a4b2d6f4a8e9b3c5d7f1a2b4c6d",
    "name": "Sales warehouse (replica)",
    "description": "Read-only replica of the sales database",
    "host": "pg.internal.example.com",
    "port": 5432,
    "username": "analytics_ro",
    "database": "sales",
    "custom_id": "sales-warehouse",
    "datasource_count": 1,
    "created_at": "2026-09-18T07:42:17.139Z",
    "updated_at": "2026-09-20T03:15:42.508Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.