TypeError: not all arguments converted during string formatting for cursor.execute(query, to_filter)

Solution
def filter_books():
conn = open_connection()
query_parameters = request.args
id = query_parameters.get('id')
published = query_parameters.get('published')
author = query_parameters.get('author')
with conn.cursor() as cursor: 
    query = 'SELECT * FROM entries WHERE'
    to_filter = []
    if id:
        query += ' id= %s  AND'
        to_filter.append(id)

    if published:
        query += ' published= %s  AND'
        to_filter.append(published)

    if author:
        query += ' author= %s  AND'
        to_filter.append(author)

    if not(id or published or author):
        return "Page not found"

    query = query[:-4] + ';'
    results = cursor.execute(query, to_filter)
    f_results=cursor.fetchall()
    return jsonify(f_results)