def find(self, id): self.cursor.execute("""SELECT * FROM """+self.tablename+""" WHERE id = %s""", (id,)) rs = self.cursor.fetchall() if not rs: return None file = File() for row in rs: file.id = row[0] file.hash = row[1] file.size = row[2] file.partialSize = row[3] file.bestName = row[4] return file
def findByHash(self, hash): query = "SELECT * FROM %s WHERE hash = '%s'" % (self.tablename, hash) self.cursor.execute(query) rs = self.cursor.fetchall() if not rs: return None file = File() for row in rs: file.id = row[0] file.hash = row[1] file.size = row[2] file.partialSize = row[3] file.bestName = row[4] return file