我使用python和sqlanydb查询Sybase Anywhere数据库文件。大多数查询都正常工作,但涉及特定表的任何选择查询:
conn = sqlanydb.connect(**{"uid":"dba", "pwd":"sql", "dbf":"file.db"})
cursor = conn.cursor()
cursor.execute("SELECT ... FROM ...")导致OperationalError,其中堆栈跟踪由于意外断开而导致通信错误-85。
---------------------------------------------------------------------------
OperationalError Traceback (most recent call last)
<ipython-input-24-2508c8b04dcc> in <module>()
1 sql = "SELECT ... FROM ..."
2 cursor = conn.cursor()
----> 3 cursor.execute(sql)
4 query_columns = [desc[0] for desc in cursor.description]
5 rows_by_date = cursor.fetchall()
/.../lib/python3.5/site-packages/sqlanydb.py in execute(self, operation, parameters)
788
789 def execute(self, operation, parameters = ()):
--> 790 self.executemany(operation, [parameters])
791
792 def callproc(self, procname, parameters = ()):
/.../lib/python3.5/site-packages/sqlanydb.py in executemany(self, operation, seq_of_parameters)
759 operation = operation.encode(self.char_set)
760 self.new_statement(operation)
--> 761 bind_count = self.api.sqlany_num_params(self.stmt)
762 self.rowcount = 0
763 for parameters in seq_of_parameters:
/.../lib/python3.5/site-packages/sqlanydb.py in __stmt_get(self)
693 self.handleerror(InterfaceError, "no statement")
694 elif not self.__stmt:
--> 695 self.handleerror(*self.parent.error())
696 return self.__stmt
697
/.../lib/python3.5/site-packages/sqlanydb.py in handleerror(self, errorclass, errorvalue, sqlcode)
687 if errorclass:
688 eh = self.errorhandler or standardErrorHandler
--> 689 eh(self.parent, self, errorclass, errorvalue, sqlcode)
690
691 def __stmt_get(self):
/.../lib/python3.5/site-packages/sqlanydb.py in standardErrorHandler(connection, cursor, errorclass, errorvalue, sqlcode)
377 cursor.messages.append(error)
378 if errorclass != Warning:
--> 379 raise errorclass(errorvalue,sqlcode)
380
381
OperationalError: (b'Communication error', -85)发布于 2017-03-18 07:34:50
李泽楷的答覆:
我放弃了,用备份的副本替换了文件,问题就解决了。我推测这张桌子不知怎么损坏了。
https://stackoverflow.com/questions/41573579
复制相似问题