Neo4j also supports transactions, meaning blocks of operations that will only alter the graph if all of them succeed.
Imagine the following situation, where you have to execute two statements:
with driver.session() as session:
session.run(statement_1)
session.run(statement_2)
If everything goes well, no problem. But what if the execution of statement_2 fails? In some cases, you would end up with inconsistent data in your graph, which is something you need to avoid. Say you are saving a new order from an existing customer. statement_1 creates the new Order node, while statement_2 creates the relationship between the Customer node and the Order node. If the execution of statement_2 fails, you will end up with an Order node, which you will not be able to link to any Customer node. In order to avoid these frustrating cases, we can use transactions instead. In a transaction, if statement_2 fails, then the whole transaction block, including statement_1, will not...