Skip to content

Instantly share code, notes, and snippets.

@rjosephwright
Created July 23, 2013 06:54
Show Gist options
  • Save rjosephwright/6060335 to your computer and use it in GitHub Desktop.
Save rjosephwright/6060335 to your computer and use it in GitHub Desktop.
class Query(Task):
@staticmethod
def executor(qname):
cx = sqlite3.connect(get_dbfile())
cx.row_factory = sqlite3.Row
queue = get_queue(qname)
while True:
task = queue.get()
for query, args in task.queries:
result = cx.execute(query, args)
cx.commit()
if result:
task.put(result)
result = None
def __init__(self):
self.queries = []
Task.__init__(self, 'Query')
def add(self, query, args):
self.queries.append((query, args))
return self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment