pg8000脚本中的套接字错误

时间:2015-04-23 17:44:39

标签: python postgresql sockets pg8000

我使用pg8000与python脚本中的postgresql数据库进行交互。我不断收到如下错误,但每次都不在同一行:

Traceback (most recent call last):
  File "C:\Users\myname\workspace2\anaconda_scripts\file_name.py", line 311, in <module>
    object_name.method_name(cur)
  File "C:\Users\myname\workspace2\anaconda_scripts\file_name.py", line 134, in method_name
    conn.commit()
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\site-packages\pg8000\core.py", line 1398, in commit
    self.execute(self._cursor, "commit", None)
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\site-packages\pg8000\core.py", line 1684, in execute
    self.handle_messages(cursor)
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\site-packages\pg8000\core.py", line 1757, in handle_messages
    self._close()
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\site-packages\pg8000\core.py", line 1419, in _close
    self._flush()
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

我对套接字了解不多,所以我尝试过/检查了以下内容:

  • 在代码
  • 中的每个conn.commit()之后添加cur.execute()
  • 而不是执行语句中的select *,我只选择了我需要的列
  • 我确保在脚本末尾包含 cur.close() conn.close()

有没有人对pg8000有任何建议或见解可以帮助我弄清楚要调查的脚本的其他方面?我已经搜索了特定的错误,但所有问题/答案似乎都是关于直接与套接字进行交互,并且我通过pg8000间接使用套接字。非常感谢任何帮助,谢谢。

0 个答案:

没有答案