aboutsummaryrefslogtreecommitdiffstats
path: root/queue2pgsql.py
diff options
context:
space:
mode:
Diffstat (limited to 'queue2pgsql.py')
-rw-r--r--queue2pgsql.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/queue2pgsql.py b/queue2pgsql.py
index 0c95f6d..253f5b4 100644
--- a/queue2pgsql.py
+++ b/queue2pgsql.py
@@ -1,23 +1,25 @@
#!/usr/bin/env python3
+''' move items from queue to database '''
import os
import time
import pickle
import sqlite3
from litequeue import SQLQueue
-from datetime import datetime
-from todb import todb
+from common import dbi
+
+QUEUE_DB = os.environ.get('el_QUEUE_db', 'litequeue.db')
# Unlock all
-con = sqlite3.connect("litequeue.db")
+con = sqlite3.connect(QUEUE_DB)
cur = con.cursor()
cur.execute("UPDATE Queue SET status = 0 WHERE status = 1")
con.commit()
con.close()
# Open Queue
-q = SQLQueue("litequeue.db", maxsize=None)
+q = SQLQueue(QUEUE_DB, maxsize=None)
q.prune()
# Event loop
@@ -28,7 +30,7 @@ while True:
continue
task = q.pop()
raw = pickle.loads(task['message'])
- todb(raw[0],raw[1])
+ dbi(raw[0],raw[1])
print("Processed " + str(task['message_id']) + ". " + str(q.qsize() - 1) + " left")
q.done(task['message_id'])