From 8d186d39483beff64a1c11f80c6ca5e56dd7bbc5 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 1 Feb 2023 20:32:11 +0100 Subject: moving and renaming/breaking everything --- scripts/common/queue.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/common/queue.py (limited to 'scripts/common/queue.py') diff --git a/scripts/common/queue.py b/scripts/common/queue.py new file mode 100644 index 0000000..e567fb4 --- /dev/null +++ b/scripts/common/queue.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +''' common functions and stuff ''' + +import os +import sys +import pickle +from litequeue import SQLQueue + +QUEUE_DB = os.environ.get('el_QUEUE_db', 'litequeue.db') + +# Initialize queue +q = SQLQueue(QUEUE_DB, maxsize=None) + +def dbi(sql,values,**kwargs): + verbose = bool(kwargs['verbose']) if 'verbose' in kwargs else False + + q.put(pickle.dumps([sql, values])) + if verbose is True: + table = sql.split(' ')[2] + num = 1 if isinstance(values, tuple) else len(values) + print("Inserted", num, "item(s) into queue for", table) + return True -- cgit v1.2.3