要获取AWS Aurora Postgres无服务器集群中的数据库名称,可以使用AWS SDK或AWS命令行界面(CLI)来查询集群的信息。
使用AWS SDK(例如AWS SDK for Python - Boto3)的代码示例:
import boto3
# 创建RDS客户端
client = boto3.client('rds')
# 获取Aurora Postgres无服务器集群的信息
response = client.describe_db_clusters(
DBClusterIdentifier='your-cluster-identifier'
)
# 从响应中提取数据库名称
db_name = response['DBClusters'][0]['DatabaseName']
print(db_name)
使用AWS CLI的命令示例:
aws rds describe-db-clusters --db-cluster-identifier your-cluster-identifier --query 'DBClusters[0].DatabaseName'
确保将"your-cluster-identifier"替换为您的Aurora Postgres无服务器集群的标识符。