从SqlAlchemy通过pg8000连接到postgres工作正常,直到我在postgres上启用了SSL。
db = create_engine('postgresql+pg8000://user:pass@hostname/dbname', echo=True).connect()
现在似乎失败了:
File "/Library/Python/2.7/site-packages/pg8000/core.py", line 872, in __init__
raise InterfaceError("communication error", exc_info()[1])
sqlalchemy.exc.InterfaceError: (InterfaceError) ('communication error', error(61, 'Connection refused')) None None
答案 0 :(得分:3)
可能你需要添加connect_args dict:
db = create_engine('postgresql+pg8000://user:pass@hostname/dbname', connect_args={'sslmode':'require'}, echo=True).connect()