While trying to update a non-existing column in a single statement throws an exception:
session.execute("UPDATE users SET wrong_column = test@test.com;")
If I do the same with multiple statements, the exception is not raised:
session.execute("UPDATE users SET email = test@test.com; UPDATE users SET wrong_column = test@test.com;")
One stackoverflow solution proposed is to split the query by the delimiter ;
:
But this does not work in my particular case as my query also consist of a few functions that have a delimiter in the RETURN ... ;
statement and then again the END;
statement, so the split would break the query.
(I know I could also try to split the query with sqlparse
but installing an extra library for that also seems weird to me)
Is there really no better way to check if all statements in a raw query were executed without error?
I also tried to find something in the CursorResult
object that is returned by the session.execute
func, but I could not find anything.
(I'm working with a MySQL DB in case it matters)