import sqlite3


def _get_fields(cursor, table_name):
    """
    get field names from sqlite3 database
    :param cursor: cursor for sqlite3 database
    :param table_name: name of the table to query for field names
    :return: list containing names of all fields in table
             if the table is not found, returns empty list.
    """
    try:
        cursor.execute("select * from {}".format(table_name))
    except sqlite3.OperationalError:
        print("error: table {} does not exist in database".format(table_name))
        return []
    names = [f[0] for f in cursor.description]
    return names