While trying to update a non-existing column in a single statement throws an exception:
session.execute("UPDATE users SET wrong_column = [email protected];")
If I do the same with multiple statements, the exception is not raised:
session.execute("UPDATE users SET email = [email protected]; UPDATE users SET wrong_column = [email protected];")
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)
executeis designed for single statements. If you want to execute multiple text statements you might be better off using the DB-API cursor, as shown in some of the answers to the Q&A that you linked.