如何通过 API 检索 AWS RDS 数据库实例中所有数据库的列表?
How can I retrieve the list of all databases in an AWS RDS DB instance via API?
有什么方法可以通过 API 或 SDK 检索 AWS RDS 数据库实例中所有数据库(或至少数据库 names)的列表(lang没关系)?
'describe-db-instances' 操作不能满足我的需要,因为它仅包含“创建时提供的此实例的初始数据库的名称”...
在文档/网络中找不到任何内容
♂️
我想避免触发 SQL 查询并最大限度地利用 API。
我已经看到了这个 SO-question,但是它是特定于 Boto3 用法的,而我不限于任何特定的 AWS SDK。
谢谢大家!
虽然您不限于 boto3,但您仅限于 AWS API 提供的内容(据我所知,boto3 涵盖了几乎所有内容)。
DescribeDBInstances API-Call returns a list of DBInstance 个对象。
每个对象都有属性 DBName
,这几乎是通过 AWS API.
公开的关于数据库架构布局的唯一信息
DBName
The meaning of this parameter differs according to the database
engine you use.
MySQL, MariaDB, SQL Server, PostgreSQL
Contains the name of the initial database of this instance that was
provided at create time, if one was specified when the DB instance was
created. This same name is returned for the life of the DB instance.
Type: String
Oracle
Contains the Oracle System ID (SID) of the created DB instance. Not
shown when the returned parameters do not apply to an Oracle DB
instance.
Type: String
这基本上就是您使用 AWS API 将获得的全部内容。如果您想要更多,则需要连接到实例并使用 RDBMS 查询该信息。 RDS 即服务实际上并不管理您实例上的模式(如果您愿意,除了创建初始模式之外)并且不会公开它们。
虽然 Mark B 和 Maurice 100% 正确,但有一个解决方法可能对其他人有用,因为用户 Optimus 在 AWS 论坛中回答了我的问题:
It's not possible because each database engine has a different
implementation of the database concept, so it's a subject that varies
from engine to engine.
What you can do is to use the ExecuteStatement RDS API command
https://docs.aws.amazon.com/rdsdataservice/latest/APIReference/API_ExecuteStatement.html
to run a select that queries the DB data dictionary for that specific
engine for that RDS instance, and then you can get the database names.
It does not avoid to run the SQL, but it is a standardized way to get
this info no matters the instance DB engine, as the result output has
always the same structure.
对我来说,这个解决方案不够好,因为我没有 ExecuteStatement
操作所需的数据库实例的 Secret-ARN。
但是,我认为其他人可能会使用此解决方法。
谢谢大家!
有什么方法可以通过 API 或 SDK 检索 AWS RDS 数据库实例中所有数据库(或至少数据库 names)的列表(lang没关系)?
'describe-db-instances' 操作不能满足我的需要,因为它仅包含“创建时提供的此实例的初始数据库的名称”...
在文档/网络中找不到任何内容
♂️
我想避免触发 SQL 查询并最大限度地利用 API。
我已经看到了这个 SO-question,但是它是特定于 Boto3 用法的,而我不限于任何特定的 AWS SDK。
谢谢大家!
虽然您不限于 boto3,但您仅限于 AWS API 提供的内容(据我所知,boto3 涵盖了几乎所有内容)。
DescribeDBInstances API-Call returns a list of DBInstance 个对象。
每个对象都有属性 DBName
,这几乎是通过 AWS API.
DBName
The meaning of this parameter differs according to the database engine you use.
MySQL, MariaDB, SQL Server, PostgreSQL
Contains the name of the initial database of this instance that was provided at create time, if one was specified when the DB instance was created. This same name is returned for the life of the DB instance.
Type: String
Oracle
Contains the Oracle System ID (SID) of the created DB instance. Not shown when the returned parameters do not apply to an Oracle DB instance.
Type: String
这基本上就是您使用 AWS API 将获得的全部内容。如果您想要更多,则需要连接到实例并使用 RDBMS 查询该信息。 RDS 即服务实际上并不管理您实例上的模式(如果您愿意,除了创建初始模式之外)并且不会公开它们。
虽然 Mark B 和 Maurice 100% 正确,但有一个解决方法可能对其他人有用,因为用户 Optimus 在 AWS 论坛中回答了我的问题:
It's not possible because each database engine has a different implementation of the database concept, so it's a subject that varies from engine to engine.
What you can do is to use the ExecuteStatement RDS API command https://docs.aws.amazon.com/rdsdataservice/latest/APIReference/API_ExecuteStatement.html to run a select that queries the DB data dictionary for that specific engine for that RDS instance, and then you can get the database names.
It does not avoid to run the SQL, but it is a standardized way to get this info no matters the instance DB engine, as the result output has always the same structure.
对我来说,这个解决方案不够好,因为我没有 ExecuteStatement
操作所需的数据库实例的 Secret-ARN。
但是,我认为其他人可能会使用此解决方法。
谢谢大家!