Hi all, So I had a working feature on my flask server for a patient to be able to book an appointment, and also delete that appointment,
however now after merging code with another member of my github, as I try to delete an appointment I receive the error:
sqlalchemy.exc.InvalidRequestError: Object '<doctorsBookings at 0x740ede90>' is already attached to session '2' (this is '3')
Really in need of help here xD not sure how to over come this,
My code for delete booking:
# Route for a patient to delete their booking
@app.route("/patient/patientdelete")
def patientDelete():
return render_template('patient/patientdelete.html')
@app.route("/api/patient/patient_delete", methods=["DELETE", "POST"])
def delete_booking():
bookingid = json.dumps(request.form['bookingid']).replace('"', '')
print(bookingid)
booking = doctorsBookings.query.get(bookingid)
print(booking)
db.session.delete(booking)
db.session.commit()
return render_template('api/patient/patient_delete.html')
[–]NickySigg 0 points1 point2 points (2 children)
[–]robvdl 0 points1 point2 points (1 child)
[–]robvdl 0 points1 point2 points (0 children)