sqlanydb 查询损坏的 SQL Anywhere table 断开连接,产生 OperationalError(通信错误 -85)

sqlanydb query on damaged SQL Anywhere table disconnects connection, produces OperationalError (Communication Error -85)

我正在使用 python 和 sqlanydb 来查询 Sybase Anywhere 数据库文件。大多数查询都有效,但任何涉及特定 table:

的 SELECT 查询
conn = sqlanydb.connect(**{"uid":"dba", "pwd":"sql", "dbf":"file.db"})
cursor = conn.cursor()
cursor.execute("SELECT ... FROM ...")

由于意外断开连接导致操作错误,堆栈跟踪暗示通信错误 -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)

[Richard C Yeh 的回答:]
我放弃了,用备份副本替换了文件,问题就消失了。我推测 table 不知何故损坏了。