aboutsummaryrefslogtreecommitdiffstats
path: root/common/queue.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-02-01 12:24:22 +0100
committerDennis Eriksen <d@ennis.no>2023-02-01 12:24:22 +0100
commitd86413ad81135454df7ef1c7d7faeb52eb51efa8 (patch)
treefaf9e7cc5bc728065f4d87f86db7c8b190ba42ed /common/queue.py
parentuse new db thingy (diff)
downloadenergyscripts-d86413ad81135454df7ef1c7d7faeb52eb51efa8.tar.gz
adding some common stuff, less code replica
Diffstat (limited to '')
-rw-r--r--common/queue.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/queue.py b/common/queue.py
new file mode 100644
index 0000000..7804c8d
--- /dev/null
+++ b/common/queue.py
@@ -0,0 +1,21 @@
+#!/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):
+ print("lolqu")
+ verbose = bool(kwargs['verbose']) if 'verbose' in kwargs else False
+
+ q.put(pickle.dumps([sql, values]))
+ if verbose is True:
+ print("Inserted into queue")
+ return True