blob: cb9042356bb6db504976b7cd6b9ad7138185cc57 (
plain) (
tree)
|
|
#!/usr/bin/env python3
''' common functions and stuff '''
import os
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):
''' insert into queue '''
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
|