繁体   English   中英

如何知道模拟 postgres 主机名?

[英]How to know mock postgres host name?

我正在尝试使用moto在 python aws lambda proyect 上创建一些单元测试。 我使用以下方法创建了一个 rds postgres 实例:

@pytest.fixture(scope='function')
def rds(aws_credentials):
    with mock_rds():
        yield boto3.client("rds", region_name="us-west-2").create_db_instance(
            DBInstanceIdentifier="db-master-1",
            AllocatedStorage=10,
            Engine="postgres",
            DBName="fox-postgres",
            DBInstanceClass="db.m1.small",
            LicenseModel="license-included",
            MasterUsername="postgres",
            MasterUserPassword="postgres",
            Port=5432,
            DBSecurityGroups=["my_sg"],
            VpcSecurityGroupIds=["sg-123456"],
            EnableCloudwatchLogsExports=["audit", "error"],
        )

我如何知道(或设置)主机名以便运行查询? 这可能吗? 我不知道这是否是一个真实的(或几乎)数据库实例。

提前致谢。

不可能针对 Moto 运行实际查询 - RDS 响应是完全模拟的。

Moto 的describe_db_instances -方法确实在Endpoint.Address -属性中返回一个端点,但这是硬编码的 - 请参阅https://github.com/getmoto/moto/blob/339309c9af4188006d9592469d52193f57249b1e/moto/rds/models.py#L674

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM