本文介绍了如何将Amazon Redshift连接到python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的python代码,我想将Amazon Redshift数据库连接到Python,但是在主机中显示错误.
This is my python code and I want to connect my Amazon Redshift database to Python, but it is showing error in host.
有人可以告诉我正确的语法吗?我可以正确传递所有参数吗?
Can anyone tell me the correct syntax? Am I passing all the parameters correctly?
con=psycopg2.connect("dbname = pg_table_def, host=redshifttest-icp.cooqucvshoum.us-west-2.redshift.amazonaws.com, port= 5439, user=me, password= secret")
这是错误:
推荐答案
您似乎希望从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")
这篇关于如何将Amazon Redshift连接到python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!