psycopg2 OperationalError:无效的连接选项

时间:2016-04-19 11:06:04

标签: python amazon-redshift psycopg

我正在使用records库连接到redshift数据库。我的db_url类似于

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

我正在使用这段代码连接到db。在我的本地机器上它完全正常。

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

但在服务器上,它给我这个错误

  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"

两台机器都安装了相同版本的库

psycopg2==2.6.1
records==0.3.0

唯一不同的是操作系统。我的本地有Mac OX而服务器在CentOS 6.7

我无法解决此错误。

1 个答案:

答案 0 :(得分:0)

我已将我的记录库升级到records==0.4.3并且它已正常工作