Beispiel #1
0
 def getAll(self):
     cm = ConnectionManager('KappaBase')
     res = cm.executeSQL("SELECT * FROM Vector")
     vectorList = []
     for elem in res:
         vectorList.append(VectorModel(elem[0], elem[1], elem[2]))
     return vectorList
Beispiel #2
0
 def getById(self, id):
     cm = ConnectionManager('KappaBase')
     res = cm.executeSQL("SELECT * FROM Vector WHERE id_vector=" + str(id))
     if (len(res) != 1):
         return
     res2 = VectorModel(res[0][0], res[0][1], elem[0][2])
     return res2
Beispiel #3
0
 def update(self, vectorModel):
     cm = ConnectionManager('KappaBase')
     res = cm.executeAndCommitSQL("UPDATE Vector SET value_vector=\"" +
                                  str(vectorModel.value) +
                                  "\" , tag_name=\"" +
                                  str(vectorModel.tagName) +
                                  "\" WHERE id_vector=" +
                                  str(vectorModel.id))
Beispiel #4
0
	def importImageFolder(self,pathF):
		print(pathF)
		y = ConnectionManager('KappaBase.db')
		l=listdir(pathF)

		#get next id
		u=self.cDao.getNextId()

		listImage = self.cDao.getAll()
		listPath =[]
		for im in listImage:
			listPath.append(im.path)

		#file in folder
		for i in l:
			pathName = join(pathF, i)
			print(pathName)
			if(isfile(pathName) and pathName not in listPath):
				print(2, pathName)

				extension = i.split(".")[1]
				if(extension in ("jpeg","jpg","png","PNG","JPEG","JPG")):
					im = open(pathName)
					path = pathName
					size = getsize(path)
					width = im.size[0]
					height = im.size[1]
					date = str(datetime.fromtimestamp(getctime(path)))

					img = ImageModel(u, "", date, height, width, size, path, None, None)
					self.create(img)
					u+=1
Beispiel #5
0
def main():
    y = ConnectionManager('KappaBase.db')
    x = ConnectionManager('KappaBase.db')
    print("test singleton")
    print(y.instance.connection == x.instance.connection)

    imgCtl = ImageController()
    rows = imgCtl.getAll()
    i = 0
    for row in rows:
        i += 1

    rows = imgCtl.getAllOrderByDate()
    j = 0
    for row in rows:
        j += 1
    print("test byDate and all")
    print(j == i)

    print("test link")
    fVecCtl = FaceVectorController()
    v = fVecCtl.getById(9)
    print(str(v.id) + " " + str(v.value) + " " + str(v.isKnown))
Beispiel #6
0
 def createWithoutCommit(self, vectorModel):
     cm = ConnectionManager('KappaBase')
     res = cm.executeSQL(
         "INSERT INTO Vector (id_vector, value_vector, tag_name) VALUES (" +
         str(vectorModel.id) + ", \"" + vectorModel.value + "\", \"" +
         vectorModel.tagName + "\")")
Beispiel #7
0
 def delete(self, vectorModel):
     cm = ConnectionManager('KappaBase')
     res = cm.executeAndCommitSQL("Delete from include WHERE id_vector=" +
                                  str(vectorModel.id))
     res = cm.executeAndCommitSQL("Delete from Vector WHERE id_vector=" +
                                  str(vectorModel.id))
Beispiel #8
0
 def __init__(self):
     self.connectionManager = ConnectionManager("KappaBase")