Looking to be able to delete a message and any comments associated with it from a link on my page. From searching, I believe I might need to do an ON DELETE CASCADE in my python code? However, I'm not too sure how to go about it? This is the last query I tried
@app.route('/messages/<id>/delete')
def delete_message(id):
query = 'DELETE FROM messages WHERE id = :id AND comments WHERE id = :id'
data = {'id':id}
mysql.query_db(query,data)
return redirect('/wall')
Tables
USERS
id
first_name
last_name
email
pw_hash
MESSAGES
id
messages
user_id
COMMENTS
id
comments
message_id
user_id
Any suggestions on how to write this out?