mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 01:02:19 +00:00
WIP executemany
This commit is contained in:
parent
61ab911747
commit
a36e010d76
2 changed files with 12 additions and 15 deletions
|
@ -23,23 +23,20 @@ def update_notifier():
|
|||
|
||||
notifiers_current = []
|
||||
for notifier in notifiers_current_db:
|
||||
notifiers_current.append(notifier['name'])
|
||||
notifiers_current.append([notifier['name']])
|
||||
|
||||
for x in results['schemas']:
|
||||
if x['service_name'] not in notifiers_current:
|
||||
notifiers_new.append(x['service_name'])
|
||||
if [x['service_name']] not in notifiers_current:
|
||||
notifiers_new.append([x['service_name'], 0])
|
||||
logging.debug('Adding new notifier agent: ' + x['service_name'])
|
||||
else:
|
||||
notifiers_old.append(x['service_name'])
|
||||
notifier_current = [i for i in notifiers_current]
|
||||
notifiers_old.append([x['service_name']])
|
||||
|
||||
notifiers_to_delete = list(set(notifier_current) - set(notifiers_old))
|
||||
notifiers_to_delete = [item for item in notifiers_current if item not in notifiers_old]
|
||||
|
||||
database.execute("INSERT INTO table_settings_notifier (name, enabled) VALUES (?, ?)", notifiers_new, execute_many=True)
|
||||
|
||||
for notifier_new in notifiers_new:
|
||||
database.execute("INSERT INTO table_settings_notifier (name, enabled) VALUES (?, ?)", (notifier_new, 0))
|
||||
|
||||
for notifier_to_delete in notifiers_to_delete:
|
||||
database.execute("DELETE FROM table_settings_notifier WHERE name=?", (notifier_to_delete,))
|
||||
database.execute("DELETE FROM table_settings_notifier WHERE name=?", notifiers_to_delete, execute_many=True)
|
||||
|
||||
|
||||
def get_notifier_providers():
|
||||
|
|
|
@ -138,11 +138,11 @@ class Sqlite3Worker(threading.Thread):
|
|||
try:
|
||||
if execute_many:
|
||||
self.sqlite3_cursor.executemany(query, values)
|
||||
if query.lower().strip().startswith(("insert", "update")):
|
||||
if query.lower().strip().startswith(("insert", "update", "delete")):
|
||||
self.results[token] = self.sqlite3_cursor.rowcount
|
||||
else:
|
||||
self.sqlite3_cursor.execute(query, values)
|
||||
if query.lower().strip().startswith(("insert", "update")):
|
||||
if query.lower().strip().startswith(("insert", "update", "delete")):
|
||||
self.results[token] = self.sqlite3_cursor.rowcount
|
||||
except sqlite3.Error as err:
|
||||
self.results[token] = (
|
||||
|
@ -153,7 +153,7 @@ class Sqlite3Worker(threading.Thread):
|
|||
def close(self):
|
||||
"""Close down the thread and close the sqlite3 database file."""
|
||||
self.exit_set = True
|
||||
self.sql_queue.put((self.exit_token, "", "", ""), timeout=5)
|
||||
self.sql_queue.put((self.exit_token, "", "", "", ""), timeout=5)
|
||||
# Sleep and check that the thread is done before returning.
|
||||
while self.thread_running:
|
||||
time.sleep(.01) # Don't kill the CPU waiting.
|
||||
|
@ -205,7 +205,7 @@ class Sqlite3Worker(threading.Thread):
|
|||
token = str(uuid.uuid4())
|
||||
# If it's a select we queue it up with a token to mark the results
|
||||
# into the output queue so we know what results are ours.
|
||||
if query.lower().strip().startswith(("select", "insert", "update")):
|
||||
if query.lower().strip().startswith(("select", "insert", "update", "delete")):
|
||||
self.sql_queue.put((token, query, values, only_one, execute_many), timeout=5)
|
||||
return self.query_results(token)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue