You need to enable JavaScript to run this app.
文档中心
AI 原生 BaaS 平台 Supabase 版

AI 原生 BaaS 平台 Supabase 版

复制全文
下载 pdf
账号管理
DescribeDBAccountConnection
复制全文
下载 pdf
DescribeDBAccountConnection
调用 DescribeDBAccountConnection 接口查询数据库账号的连接信息。​
请求类型​
同步请求。​
注意事项​
该接口仅能用于操作使用 PostgreSQL 引擎和 veDB MySQL 引擎的 Workspace(工作区)。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
​
参数​
类型​
是否必选​
示例值​
描述​
WorkspaceId​
String​
是​
noble-heath-3a48****​
Workspace 的 ID。​
BranchId​
String​
是​
br-merry-scup-42d3****​
分支 ID。​
ComputeId​
String​
是​
cp-cute-fresh-0e7d****​
算力 ID。​
AccountName​
String​
否​
test-user​
账户名称。​
DatabaseName​
String​
是​
test-db​
数据库名称。​
AddressId​
String​
否​
addr-78c22739ee479f6e****​
地址的 ID。可调用 DescribeWorkspaceEndpoint 接口查询指定 Workspace 的连接信息。​
说明​
如不指定,则返回公网连接信息。​
​
返回参数​
​
参数​
类型​
示例值​
描述​
AccountName​
String​
test-user​
账号名称。​
AccountPassword​
String​
ynqz*uhwWwK&****​
账号密码。​
AllowHost​
String​
[\"0.0.0.0/0\", \"::/0\"]​
允许连接工作区的域名。​
BranchId​
String​
br-merry-scup-42d3****​
分支 ID。​
ComputeId​
String​
cp-cute-fresh-0e7d****​
算力 ID。​
ConnectionExamples​
Array of ConnectionExample​
请参见返回示例。​
连接示例。​
ConnectionUrl​
String​
psql 'postgresql://test-user:ynqz%2AuhwWwK%26%5****@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require'​
连接字符串。​
DatabaseName​
String​
test-db​
数据库名称。​
WorkspaceId​
String​
noble-heath-3a48****​
Workspace 的 ID。​
​
ConnectionExample​
​
参数​
类型​
示例值​
描述​
ConnectionExample​
String​
postgresql://test-user:ynqz%2AuhwWwK%26%5****@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require​
对应语言类型的连接字符串。​
ConnectionType​
String​
psql​
连接字符串的类型,取值:​
  • psql​
  • ConnectionString​
  • Parameters​
  • Golang​
  • Java​
  • Django​
​
示例​
请求示例​
​
POST /?Action=DescribeDBAccountConnection&Version=2025-10-01 HTTP/1.1​
Content-Type: application/json​
Host: aidap.cn-beijing.volcengineapi.com​
X-Date: 20251001T101010Z​
Authorization: HMAC-SHA256 Credential=AKLTN2I0MmFiNzMxNWE5NDgzMzk4MmVjMTVkODlkZTZ****/20251001/cn-beijing/aidap/request,SignedHeaders=x-date, Signature=71d31fc7bcf990142851c9833c5656391486cda0ae2e0b8ada733b7c6458****​
{​
"WorkspaceId": "noble-heath-3a48****",​
"BranchId": "br-merry-scup-42d3****",​
"ComputeId": "cp-cute-fresh-0e7d****",​
"EndpointId": "ep-15d73b055d662534****",​
"AccountName": "test-user",​
"DatabaseName": "test-db"​
}​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "202510161906237ACF29F5823D67C958B1-db70b1",​
"Action": "DescribeDBAccountConnection",​
"Version": "2025-10-01",​
"Service": "aidap",​
"Region": "cn-beijing"​
},​
"Result": {​
"AccountName": "test-user",​
"AccountPassword": "ynqz*uhwWwK&^MuO",​
"AllowHost": "[\"0.0.0.0/0\", \"::/0\"]",​
"BranchId": "br-alert-duck-3bdf****",​
"ComputeId": "cp-sure-tide-9371****",​
"ConnectionExamples": [​
{​
"ConnectionExample": "psql 'postgresql://test-user:ynqz%2AuhwWwK%26%5EMuO@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require'",​
"ConnectionType": "psql"​
},​
{​
"ConnectionExample": "postgresql://test-user:ynqz%2AuhwWwK%26%5EMuO@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require",​
"ConnectionType": "ConnectionString"​
},​
{​
"ConnectionExample": "PGHOST='cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com'\nPGDATABASE='test-db'\nPGUSER='test-user'\nPGPASSWORD='ynqz*uhwWwK&^MuO'\nPGSSLMODE='require'\nPGCHANNELBINDING='require'\n",​
"ConnectionType": "Parameters"​
},​
{​
"ConnectionExample": "package main\nimport (\n\t\"context\"\n\t\"github.com/jackc/pgx/v5\"\n)\n\nfunc main() {\n\tconnStr := \"postgresql://test-user:ynqz%2AuhwWwK%26%5EMuO@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require\"\n\tconn, err := pgx.Connect(context.Background(), connStr)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer conn.Close(context.Background())\n\t// do something with conn. such as CREATE TABLE、INSERT DATA\n\t_, err = conn.Exec(context.Background(), \"CREATE TABLE users (id SERIAL PRIMARY KEY, name VARCHAR(50) NOT NULL, email VARCHAR(100) UNIQUE,age INT,created_at TIMESTAMP DEFAULT now());\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n",​
"ConnectionType": "Golang"​
},​
{​
"ConnectionExample": "package com.test.aidb;\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\npublic class ConnectExample {\n public static void main(String[] args) {\n // connection url\n String url = \"jdbc:postgresql://cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?user=test-user&password=ynqz%2AuhwWwK%26%5EMuO&channelBinding=require&sslmode=require\";\n\n try (Connection conn = DriverManager.getConnection(url)) {\n if (conn != null) {\n System.out.println(\"successfully connected to DB\");\n } else {\n System.out.println(\"failed to make connection!\");\n }\n } catch (SQLException e) {\n e.printStackTrace();\n }\n }\n}\n",​
"ConnectionType": "Java"​
},​
{​
"ConnectionExample": "import psycopg2\nfrom urllib.parse import urlparse, parse_qsl, unquote\n\nconnection_url = (\n\t'postgresql://test-user:ynqz%2AuhwWwK%26%5EMuO@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require'\n)\n\n# parse connection url\nconnection_data = urlparse(connection_url)\n\n# define database settings\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.postgresql',\n 'NAME': connection_data.path.lstrip('/'),\n 'USER': connection_data.username,\n 'PASSWORD': unquote(connection_data.password),\n\t'HOST': connection_data.hostname,\n 'PORT': connection_data.port or 5432,\n 'OPTIONS': dict(parse_qsl(connection_data.query)),\n }\n}\n\n# connect to database using psycopg2\ndb_conf = DATABASES['default']\nconn = psycopg2.connect(\n dbname=db_conf['NAME'],\n user=db_conf['USER'],\n password=db_conf['PASSWORD'],\n host=db_conf['HOST'],\n port=db_conf['PORT'],\n sslmode=db_conf['OPTIONS'].get('sslmode', 'require'),\n)\n\ncur = conn.cursor()\n\n# query all tables in current database except system tables\ncur.execute(\"\"\"\n SELECT schemaname, tablename\n FROM pg_tables\n WHERE schemaname NOT IN ('pg_catalog', 'information_schema')\n ORDER BY schemaname, tablename;\n\"\"\")\n\ntables = cur.fetchall()\nfor schema, table in tables:\n print(f\" - {schema}.{table}\")\n\ncur.close()\nconn.close()\n",​
"ConnectionType": "Django"​
}​
],​
"ConnectionUrl": "psql 'postgresql://test-user:ynqz%2AuhwWwK%26%5EMuO@cp-sure-tide-9371****.pg.aidap-global.cn-beijing.volces.com/test-db?sslmode=require&channel_binding=require'",​
"DatabaseName": "",​
"WorkspaceId": "noble-heath-3a48****"​
}​
}​
​
错误码​
更多详情,请参见错误码。​
最近更新时间:2026.06.24 10:58:45
这个页面对您有帮助吗?
有用
有用
无用
无用