db maintennanace

This commit is contained in:
ville rantanen
2014-01-30 10:04:10 +02:00
parent 5b75250fbd
commit 7d65866630

View File

@@ -75,6 +75,19 @@ def delete_nonexisting(sqlfile):
print('removing.. '+row[0]) print('removing.. '+row[0])
dbdel.execute("DELETE FROM list where file == ?",(row[0],)) dbdel.execute("DELETE FROM list where file == ?",(row[0],))
conn.commit() conn.commit()
# database may have duplicate files due to crash etc..
db.execute("SELECT file,date,count(*) FROM list GROUP BY file HAVING count(*) > 1 ")
dupfile=[]
for row in db:
print(row)
#hash=row[0]
#dbh.execute("SELECT file,width,height,date FROM list WHERE hash = ?",(hash,))
#flist=[]
#for row in dbh:
# flist.append(row)
#flist.sort(key=lambda file: file[3])
#duphash.append((hash, flist))
#duphash.sort(key=lambda file: file[1][0])
return return
def delete_files(files): def delete_files(files):