prof_api/helper_functions.py
def general_get(professor, add_query='', *options):
    """
    General function for querying in database for professor and returning
    JSON formatted result

    :param professor: In forms of sqlite database name (Last, First)
    :param add_query:
    :param options:
    :return:
    """
    query = 'SELECT course.*, stats.*, grades.* FROM professor ' \
            'INNER JOIN association ON professor.id = association.professor_id ' \
            'INNER JOIN course ON course.id = association.course_id ' \
            'INNER JOIN stats ON course.id=stats.course_id ' \
            'INNER JOIN grades ON course.id = grades.course_id ' \
            'WHERE professor.name = ? ' + add_query

    conn = sqlite3.connect(app.config['DATABASE_NAME'])
    conn.row_factory = result_to_json
    cur = conn.cursor()
    new_options = [professor] + [x for x in options if x != 'fetchone']
    if 'fetchone' in options:
        results = cur.execute(query, new_options).fetchone()
    else:
        results = cur.execute(query, new_options).fetchall()

    return jsonify(results)

    General function for querying in database for professor and returning
    JSON formatted result

    :param professor: In forms of sqlite database name (Last, First)
    :param add_query:
    :param options:
    :return:
    
General function for querying in database for professor and returning
JSON formatted result
General function for querying in database for professor and returning JSON formatted result
def general_get(professor, add_query='', *options):
    query = 'SELECT course.*, stats.*, grades.* FROM professor ' \
            'INNER JOIN association ON professor.id = association.professor_id ' \
            'INNER JOIN course ON course.id = association.course_id ' \
            'INNER JOIN stats ON course.id=stats.course_id ' \
            'INNER JOIN grades ON course.id = grades.course_id ' \
            'WHERE professor.name = ? ' + add_query
    conn = sqlite3.connect(app.config['DATABASE_NAME'])
    conn.row_factory = result_to_json
    cur = conn.cursor()
    new_options = [professor] + [x for x in options if x != 'fetchone']
    if 'fetchone' in options:
        results = cur.execute(query, new_options).fetchone()
    else:
        results = cur.execute(query, new_options).fetchall()
    return jsonify(results)
def general_get ( professor , add_query = '' , * options ) : query = 'SELECT course.*, stats.*, grades.* FROM professor ' 'INNER JOIN association ON professor.id = association.professor_id ' 'INNER JOIN course ON course.id = association.course_id ' 'INNER JOIN stats ON course.id=stats.course_id ' 'INNER JOIN grades ON course.id = grades.course_id ' 'WHERE professor.name = ? ' + add_query conn = sqlite3 . connect ( app . config [ 'DATABASE_NAME' ] ) conn . row_factory = result_to_json cur = conn . cursor ( ) new_options = [ professor ] + [ x for x in options if x != 'fetchone' ] if 'fetchone' in options : results = cur . execute ( query , new_options ) . fetchone ( ) else : results = cur . execute ( query , new_options ) . fetchall ( ) return jsonify ( results )
General function for querying in database for professor and returning
JSON formatted result
General function for querying in database for professor and returning JSON formatted result
"""
    General function for querying in database for professor and returning
    JSON formatted result

    :param professor: In forms of sqlite database name (Last, First)
    :param add_query:
    :param options:
    :return:
    """
None
professor
In forms of sqlite database name (Last, First)
In forms of sqlite database name ( Last First )
add_query
None
options
None