Search code examples
pythonamazon-redshiftpsycopg

psycopg2 OperationalError: invalid connection option


I am using records library to connect to redshift database. My db_url is something like

postgresql://xxxxx.us-east-1.redshift.amazonaws.com:5439/customer?user=xxxxx&password=xxxxx

I am using this piece of code to connect to db. On my local machine it works perfectly fine.

import records
>>> conn_url = 'postgresql://xxxxx.us-east-1.redshift.amazonaws.com:5439/customer?user=xxxxx&password=xxxxx'
>>> db = records.Database(conn_url)

but on the server machine its giving me this error

  File "<stdin>", line 1, in <module>
  File "/opt/extractor/virtualenv/hge/lib/python2.7/site-packages/records.py", line 177, in __init__
    self.db = psycopg2.connect(self.db_url, cursor_factory=RecordsCursor)
  File "/opt/extractor/virtualenv/hge/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)

psycopg2.OperationalError: invalid connection option "postgresql://xxxxx.us-east-1.redshift.amazonaws.com:5439/customer?user"

Both the machines have same version of library installed

psycopg2==2.6.1
records==0.3.0

The only thing that differ is the OS. My local has Mac OX whereas the server is on CentOS 6.7

I am not able to fix this error.


Solution

  • I have upgraded my records library to records==0.4.3 and it worked