I have the following code to work with my files. If file is added to the database before, then the file is just skipped (pass
).
import sqlite3 as lite
for i, file in enumerate( allMedia ):
con = lite.connect(DB_PATH)
con.text_factory = str
with con:
cur = con.cursor()
cur.execute("SELECT rowid,files_id,path,set_id,md5,tagged FROM files WHERE path = ?", (file,))
row = cur.fetchone()
if (row is not None):
pass
The problem with this code is slow processing (2-3 seconds for each file found in the database). The database size is ~30 Mb. And thousands of files should be processed.
Is there any way to speed up the process?