def _send_digest_scheduled(run_date: datetime) -> bool: with connection.cursor() as cursor: sql = '''select exists(select id from task_task where name = %s and (kwargs->>'run_date')::timestamptz = %s)''' return fetch_bool(cursor, SQLClause(sql, [SendDigest.name, run_date]))