def table_is_empty(db_session, table_name, query_id):
    try:
        c = db_session.cursor()
        if table_name == "albums": # albums
            c.execute("""SELECT 1 FROM %s WHERE artist_id = ? LIMIT 1""" % table_name, [query_id])
        elif table_name == "songs":
            c.execute("""SELECT 1 FROM %s WHERE album_id = ? LIMIT 1""" % table_name, [query_id])
        result = c.fetchone()
        #db_session.commit()
        c.close()
        if result is not None:
            return False # not empty
    except:
        pass
    return True
Check to see if a portion of the table is empty.
dataset/ETHPy150Open bahamas10/Viridian/AmpacheTools/dbfunctions.py/table_is_empty