且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将Amazon Redshift连接到python

更新时间:2021-09-29 10:21:53

您似乎希望从Python代码运行Amazon Redshift查询.

It appears that you wish to run Amazon Redshift queries from Python code.

您要使用的参数是:

  • 数据库名称:这是创建集群时在Database name字段中输入的数据库的名称.
  • 用户:创建集群时,您是在Master user name字段中输入的.
  • 密码:这是您在创建集群时在Master user password字段中输入的.
  • 主机:这是Redshift管理控制台中提供的端点(末尾没有端口):redshifttest-xyz.cooqucvshoum.us-west-2.redshift.amazonaws.com
  • 端口: 5439
  • dbname: This is the name of the database you entered in the Database name field when the cluster was created.
  • user: This is you entered in the Master user name field when the cluster was created.
  • password: This is you entered in the Master user password field when the cluster was created.
  • host: This is the Endpoint provided in the Redshift management console (without the port at the end): redshifttest-xyz.cooqucvshoum.us-west-2.redshift.amazonaws.com
  • port: 5439

例如:

con=psycopg2.connect("dbname=sales host=redshifttest-xyz.cooqucvshoum.us-west-2.redshift.amazonaws.com port=5439 user=master password=secret")