I have a sqlite table containing a column of filenames. Some filenames are duplicates of other files, so I'd like to iterate through each row, search the column for similar entries, and print those results to the console.
A print(row[0])
indicates that the first half of my findDupes
loop works, iterating through each row. Things get weird when I make another sqlite statement to find similar entries and print the output. Instead of continuing with the loop, the loop only prints the first entry.
I'm not a SQL expert, so there's no telling what I'm doing wrong. Any help would be greatly appreciated. Thanks!
def getFiles():
dirs = os.listdir(path)
for files in dirs:
c.execute('INSERT INTO myTable(files) VALUES(?)', (files,))
def findDupes():
row = c.execute('select files from myTable order by files')
while True:
row = c.fetchone()
if row == None:
break
c.execute('select files from myTable where files like ?',(row[0]+'%',))
dupe = c.fetchone()
print (dupe[0])