connect
Open a database session to MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, or Oracle; returns table details and permission mode, replacing any prior session.
Instructions
连接到数据库。支持 MySQL、MariaDB、PostgreSQL、SQLite、MSSQL、Oracle。传入连接参数后会建立新连接,之前的连接会被自动关闭。SQLite 只需要传 filepath 参数;PostgreSQL/MSSQL/Oracle 可通过 schema 指定命名空间,不传则列出所有非系统 schema;Oracle 的 database 参数表示 service name 或 TNS connect string;MSSQL 在 SQL Server 2019+ 默认要求加密,自签证书环境需将 trustServerCertificate 设为 true。连接成功后返回当前数据库的表信息列表与当前权限模式(权限模式仅由 server 启动配置决定,无法通过此工具修改)。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | 数据库主机地址(SQLite 不需要) | localhost |
| port | No | 数据库端口(0 表示使用默认端口:MySQL/MariaDB 3306,PostgreSQL 5432,MSSQL 1433,Oracle 1521) | |
| type | Yes | 数据库类型 | |
| user | No | 数据库用户名(SQLite 不需要) | |
| schema | No | 仅 PostgreSQL/MSSQL/Oracle 使用:schema 名称;不传则列出所有非系统 schema | |
| encrypt | No | 仅 MSSQL 使用:是否启用 TLS 加密(SQL Server 2019+ 默认要求),默认 true | |
| database | No | 数据库名(SQLite 不需要;Oracle 填 service name 或 TNS connect string) | |
| filepath | No | SQLite 数据库文件路径(仅 SQLite 使用) | |
| password | No | 数据库密码(SQLite 不需要) | |
| trustServerCertificate | No | 仅 MSSQL 使用:是否信任自签证书(开发/局域网常用),默认 false |