def run_q(db, q, *args, **kwargs):
  """
  Helper function to turn database query results into list of python dicts
  """
  if args and kwargs:
    cur = db.execute(q, *args, **kwargs)
  elif args:
    cur = db.execute(q, *args)
  elif kwargs:
    cur = db.execute(q, **kwargs)
  else:
    cur = db.execute(q)
  keys = list(cur.keys())
  data = []
  for row in cur:
    data.append(dict(list(zip(keys, list(row)))))
  return data