我遇到了一个在 Python 类中定义的函数的问题:
class DatabaseHandler:
def get_messages_by_last_mid(self, uidReceiver, last_mid):
self.cursor.execute("SELECT uidSender, content FROM messages WHERE MID > ?", str(last_mid))
ret_value = []
result = self.cursor.fetchone()
while result != None:
ret_value.append(result)
result = self.cursor.fetchone()
return ret_value
def get_messages_by_last_group_id(self, uidReceiver, last_gid):
self.cursor.execute("SELECT gidreceiver, uidsender, content FROM groupmessages WHERE mid > ?", str(last_gid))
ret_value = []
result = self.cursor.fetchone()
while result != None:
ret_value.append(result)
result = self.cursor.fetchone()
return ret_value
但只有函数 get_messages_by_last_mid() 有效,另一个产生以下错误:
AttributeError: DatabaseHandler instance has no attribute 'get_messages_by_last_group_id'
提前致谢 :)