0
votes

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'

ERROR - 'pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53); [01S00] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0)')'

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

ERROR - 'pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')'

Any help would be much appreciated. Thanks!

1
I am trying to run this script from Amazon Workspace. I have successfully added the RedShift cluster as an ODBC data source. However the Python script fails to connect.Pritz

1 Answers

0
votes

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

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

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

'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

This has fixed the problem.