【问题标题】:How to connect to PostgreSQL from postman script for automated api test如何从邮递员脚本连接到 PostgreSQL 以进行自动化 api 测试
【发布时间】:2021-04-16 05:14:13
【问题描述】:

我正在尝试找到一种从邮递员连接数据库的方法以及如何完成?

【问题讨论】:

    标签: postgresql postman


    【解决方案1】:

    您无法将邮递员连接到外部 api:

    Postman 在测试脚本和预请求部分仅允许以下 nodejs 库列表:

    https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#using-external-libraries

    你可以使用原生 js 库,如果它有一个相当于 cdn 的内容请看这里的讨论:

    https://community.postman.com/t/adding-external-libraries-to-postman/1971/8

    所以要回答你的问题,最好的方法是编写一个 nodejs 程序来连接到 postgresSQL 并通过使用 express API 包装它来公开它。这样邮递员就可以访问结果。

    还请查看以下示例集合是否有帮助:

    https://documenter.getpostman.com/view/5922408/RznJmGfn#ed6af38c-dd01-4a9c-9e40-d1071276d6a0

    【讨论】:

      【解决方案2】:

      将 Postman 连接到 Postgres 使用 https://github.com/PostgREST/postgrest 之类的工具来设置 REST API。

      【讨论】:

        猜你喜欢
        • 2021-11-08
        • 2017-02-21
        • 2017-05-19
        • 2021-05-30
        • 1970-01-01
        • 1970-01-01
        • 2019-05-14
        • 2021-01-08
        相关资源
        最近更新 更多