1

我正在使用记录库连接到红移数据库。我的 db_url 类似于

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

我正在使用这段代码连接到数据库。在我的本地机器上它工作得很好。

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

我无法修复此错误。

4

1 回答 1

0

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

于 2016-04-19T12:35:15.367 回答