OperationalError: (OperationalError) no such column
I have a problem. I have to do this query:
@app.route('/api/subscriptions/<string:id>', methods=('DELETE',))
@decorators.login_required
def delete_subscription(id):
dbsession = DBSession()
session = Session()
favorit = (dbsession.query(StudentsFavorites)
.filter(Exams.number == str(id))
.filter(StudentsFavorites.exam_id)
.filter(Students.id == StudentsFavorites.student_id)
.filter(Students.id == str(session.get_user_id()))
.delete() )
dbsession.flush()
return jsonify(error=False)
But when I do this query I get this exception:
OperationalError: (OperationalError) no such column: exams.number u'DELETE
FROM students_favorites WHERE exams.number = ? AND
students_favorites.exam_id AND students.id = students_favorites.student_id
AND students.id = ?' ('123123123', 'a24213')
The tables are very big and got lots of information, so i can't post all
of it. But this query works:
@app.route('/api/subscriptions/<string:id>', methods=('PUT',))
@decorators.login_required
def add_subscription(id):
dbsession = DBSession()
session = Session()
examID = (dbsession.query(Exams.id)
.filter(Exams.number == id).first()
)
favorit=StudentsFavorites(student_id=session.get_user_id(),
exam_id=examID.id)
dbsession.add(favorit)
dbsession.flush()
return jsonify(error=False)
Short view to the table:
table: Exams
rows: id, number (number is the id i put into the function)
table: StudentsFavorites
rows: student_id, exams_id
table: Students
rows: id
I really didn't understand, why he didn't find the number row in the
exception.
No comments:
Post a Comment