I am struggling with my final project. I need to join 2 Tables "book" and "idlist" and execute the values in index.html. Here is python and html code (also idlist Tablebook Table). If someone knows where is a mistake, I will be grateful!
@app.route("/", methods=["GET", "POST"])
@login_required
def index():
"""Show reading list"""
if request.method == "GET":
# Execute list joining "book" and "idlist" tables
list = db.execute("SELECT Title1, Status, LastUpdate, Author, Year, Country, Language FROM idlist INNER JOIN book on idlist.Title1=book.Title WHERE id=:id",
id=session["user_id"])
# If the user has no list yet
if not list:
el = {'Title1': "No", 'Author': "No", 'Year': "No", 'Country': "No", 'Language': "No", 'Status': "No", 'LastUpdate': "No"}
return render_template("index.html")
else:
return render_template("index.html")
return render_template("index.html")
html should execute the values from the joined tables
{% extends "layout.html" %}
{% block title %}
Index
{% endblock %}
{% block main %}
<table style="width:100%">
<tr>
<th>Title</th>
<th>Author</th>
<th>Year</th>
<th>Country</th>
<th>Language</th>
<th>Status</th>
<th>Last update</th>
</tr>
{% for el in list %}
<tr>
<td>
{{ el.Title1 }}
</td>
<td>
{{ el.Author }}
</td>
<td>
{{ el.Year }}
</td>
<td>
{{ el.Country }}
</td>
<td>
{{ el.Language }}
</td>
<td>
{{ el.Status }}
</td>
<td>
{{ el.LastUpdate }}
</td>
</tr>
{% endfor %}
</table>
{% endblock %}
Here is the error while I login with user id 16: RuntimeError: near "update": syntax error [SQL: 'SELECT Title, Status, update, Author, Year, Country, Language FROM idlist INNER JOIN book on idlis t.Title=book.Title WHERE id=16']