예제 #1
0
 def testInsert(self):
     fdao = FileDAO()
     file = File()
     file.hash = self.hash
     file.size = 555555 
     file.partialSize = 55555
     file.bestname = 'nomedoarquivonarede.ext'
     fid = fdao.insert(file)
     assert fid != -1, 'error inserting file'
예제 #2
0
 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
예제 #3
0
 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