def _gen_jid(cur):
    '''
    Generate an unique job id
    '''
    jid = salt.utils.jid.gen_jid(__opts__)
    sql = '''SELECT jid FROM jids WHERE jid = %s'''
    cur.execute(sql, (jid,))
    data = cur.fetchall()
    if not data:
        return jid
    return None