示例#1
0
def getAllIds():
    """ Method to read all jobs from jobtabelle

    Args: -

    Returns:
    jobIds (list): the record matching the id
    """
    with jobdb:
        queryResult = Job.select(getattr(Job, JOBTABLE.id_field)).dicts()

    jobIds = []

    # iterating reopens db connection!!
    for i in queryResult:
        jobIds.append(i[JOBTABLE.id_field])

    log.debug("Information read from jobtable.")

    jobdb.close()

    return jobIds
示例#2
0
def getJobById(jobid):
    """ Method to read job from jobtabelle by id

    Args:
    jobid (int): id of job

    Returns:
    record (dict): the record matching the id
    """
    try:
        with jobdb:
            queryResult = Job.select().where(
                getattr(Job, JOBTABLE.id_field) == jobid).get()
        record = model_to_dict(queryResult)
        log.info("Information read from jobtable for job with id " +
                 str(record['idpk_jobs']) + ".")

    except Job.DoesNotExist:
        record = None

    jobdb.close()

    return record