如何使用Python连接到我的Amazon RedShift集群? [英] How do I connect to my Amazon RedShift cluster using Python?

查看:262
本文介绍了如何使用Python连接到我的Amazon RedShift集群?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有到我的Amazon RedShift集群的ODBC URL.我编写了一个简单的Python脚本来连接到集群,但是连接一直失败.

I have the ODBC url to my Amazon RedShift cluster. I wrote a simple Python script to connect to the cluster, however the connection keeps failing.

我尝试了以下连接字符串;

I have tried the following connection strings;

1)'Driver={SQL Server}; Server=$SERVER; Database=$DB; UID=$UID; PWD=$PWD; Port=5439'

错误-'pyodbc.错误:('08001','[08001] [Microsoft] [ODBC SQL Server驱动程序] [DBNETLIB] SQL Server不存在或访问被拒绝.(17)(SQLDriverConnect); [01000] [Microsoft] [ODBC SQL Server驱动程序] [DBNETLIB] ConnectionOpen(Connect()).(53); [01S00] [Microsoft] [ODBC SQL Server驱动程序]无效的连接字符串属性(0)')'

2)'Driver={Amazon Redshift (x64)}; Server=$SERVER; Database=$DB; UID=$UID; PWD=$PWD; Port=5439'

错误-'pyodbc.Error :('IM002','[IM002] [Microsoft] [ODBC驱动程序管理器]数据源名称未找到且未指定默认驱动程序(0)(SQLDriverConnect)')'

任何帮助将不胜感激.谢谢!

Any help would be much appreciated. Thanks!

推荐答案

好的,因此,在进行了大量的故障排除之后,我找到了解决方案!

Ok so after a lot of troubleshooting, I found the solution!

在文件"odbc.ini"中,"Driver32"具有以下值:

In the file 'odbc.ini', 'Driver32' had the following value:

Driver32=C:\Program Files\Amazon Redshift ODBC Driver\lib\AmazonRedshiftODBC64.dll

'Driver32'指向64位文件.结果,我下载了32位驱动程序并将路径更新为:

'Driver32' is pointing to a 64 bit file. As a result I downloaded the 32 bit driver and updated the path to:

Driver32=C:\Program Files (x86)\Amazon Redshift ODBC Driver\lib\AmazonRedshiftODBC32.dll

这已解决了问题.

这篇关于如何使用Python连接到我的Amazon RedShift集群?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆