从 NodeJS Express 应用程序查询 Redshift (@aws-sdk/client-redshift-data)

问题描述 投票:0回答:1

我有一个简单的 Express 应用程序,我正在尝试弄清楚如何使用“@aws-sdk/client-redshift-data”模块从 AWS Redshift 获取数据。

按照模块 GitHub 页面中的示例代码,我正在执行以下操作:

const {
  RedshiftDataClient,
  ListSchemasCommand,
} = require("@aws-sdk/client-redshift-data");

const client = new RedshiftDataClient({ region: "eu-central-1" });

  console.log(`RedshiftDataClient created :::: ${JSON.stringify(client)}`);

  const params = {
    /** input parameters */
  };
  const command = new ListSchemasCommand(params);

  try {
    const data = await client.listSchemas(command);
    // process data.
    console.log(`PROCESSING DATA :::: ${JSON.stringify(data)}`);
  } catch (error) {
    // error handling.
    console.log(`LIST SCHEMAS ERROR :::: ${error}`);
  }

来源:https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-redshift-data

我收到一条错误消息:

TypeError: client.listSchemas is not a function

看起来我通过构造函数创建的 RedshiftDataClient 不符合预期的格式。这是我登录时得到的结果:

{
  "middlewareStack": {},
  "config": {
    "apiVersion": "2019-12-20",
    "disableHostPrefix": false,
    "extensions": [],
    "httpAuthSchemes": [
      {
        "schemeId": "aws.auth#sigv4",
        "signer": {}
      }
    ],
    "logger": {},
    "serviceId": "Redshift Data",
    "runtime": "node",
    "requestHandler": {
      "metadata": {
        "handlerProtocol": "http/1.1"
      },
      "configProvider": {}
    },
    "defaultSigningName": "redshift-data",
    "tls": true,
    "isCustomEndpoint": false,
    "systemClockOffset": 0,
    "signingEscapePath": true
  }
}

它没有“listSchemas”或任何其他方法。

我可能会错过什么?谢谢

amazon-web-services amazon-redshift aws-sdk aws-sdk-nodejs
1个回答
1
投票

RedshiftDataClient
RedshiftData
之间有区别。看起来您正在组合两者的语法。

您要么想要:

const client = new RedshiftDataClient({});
client.send(new ListSchemasCommand({}))

const client = new RedshiftData({});
client.listSchemas({})

https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/introduction/

© www.soinside.com 2019 - 2024. All rights reserved.