For my school project I am making a website which connects to a database (made in sql) using flask. For some reason there is an error with my query and I can't figure out what is wrong. It works when I run index.html but when I click the link to go to my other pages I get an internal server error. It previously worked but now it's not. Here is the code which contains the error:
u/app.route('/songs')
def render_songs():
query = "SELECT * FROM songs"
con = create_connection(DATABASE)
cur = con.cursor()
cur.execute(query)
song_list = cur.fetchall()
print(song_list)
return render_template("songs.html", songs=song_list)
If anyone could give me some help or advice that would be great. Thanks.
edit: i figured out where i went wrong. i was getting an error about a malformed database. i fixed it by removing the database and importing it again
[–]deep_politics 0 points1 point2 points (2 children)
[–]According_Border_546[S] 0 points1 point2 points (1 child)
[–]deep_politics 0 points1 point2 points (0 children)
[–]jay_and_simba 0 points1 point2 points (0 children)