I made a search system for project 1 that returns the author, title, and year of publication of a book when you give the ISBN. However, my code is returning extra characters. If I input the ISBN 0307279464, I get the output: ('A Walk in the Woods',) by ('Bill Bryson',) Published in (1997,) Why is it outputting extra characters and how can I fix this?
Here is my code for application.py:
def bookpage():
bookisbn = request.args.get("bookisbn")
author=db.execute("SELECT author FROM books WHERE isbn = :isbn",
{"isbn":bookisbn}).fetchone()
title=db.execute("SELECT title FROM books WHERE isbn = :isbn",
{"isbn":bookisbn}).fetchone()
year=db.execute("SELECT year FROM books WHERE isbn = :isbn",
{"isbn":bookisbn}).fetchone()
if author != None and title != None and year != None:
return render_template("bookpage.html", author=author, title=title, year=year)
else:
return render_template("error404.html")
Here is the HTML code for the search bar, which is part of a Bootstrap navbar:
<input class="form-control mr-sm-2" type="search" name="bookisbn" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search by ISBN</button>
</form>
Here is the HTML code for the book page:
{% block head %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
{% endblock %}
{% block body %}
<h1 text-align=center> {{title}} by {{author}} </h1>
<h2 text-align=center> Published in {{year}} </h2>
{% endblock %}
My book database does not have any of these extra characters that are being returned. Why am I seeing extra characters and how can I remove them? I have already tried using python replace and translate functions.