Further speed up add_file
This commit is contained in:
parent
05c96dc1c6
commit
2319d2fc9c
1 changed files with 7 additions and 7 deletions
|
@ -191,18 +191,18 @@ class KodiDBMethods(object):
|
||||||
Adds the filename [unicode] to the table files if not already added
|
Adds the filename [unicode] to the table files if not already added
|
||||||
and returns the idFile.
|
and returns the idFile.
|
||||||
"""
|
"""
|
||||||
query = 'SELECT idFile FROM files WHERE idPath = ? AND strFilename = ?'
|
self.cursor.execute('SELECT idFile FROM files WHERE idPath = ? AND strFilename = ?',
|
||||||
self.cursor.execute(query, (path_id, filename))
|
(path_id, filename))
|
||||||
try:
|
try:
|
||||||
file_id = self.cursor.fetchone()[0]
|
file_id = self.cursor.fetchone()[0]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.cursor.execute('SELECT COALESCE(MAX(idFile), 0) FROM files')
|
self.cursor.execute('SELECT COALESCE(MAX(idFile), 0) FROM files')
|
||||||
file_id = self.cursor.fetchone()[0] + 1
|
file_id = self.cursor.fetchone()[0] + 1
|
||||||
query = '''
|
self.cursor.execute('''
|
||||||
INSERT INTO files(idFile, idPath, strFilename, dateAdded)
|
INSERT INTO files(
|
||||||
|
idFile, idPath, strFilename, dateAdded)
|
||||||
VALUES (?, ?, ?, ?)
|
VALUES (?, ?, ?, ?)
|
||||||
'''
|
''',
|
||||||
self.cursor.execute(query,
|
|
||||||
(file_id, path_id, filename, date_added))
|
(file_id, path_id, filename, date_added))
|
||||||
return file_id
|
return file_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue