--- title: "system.db.rollbackTransaction" description: "Performs a rollback on the given connection." --- # system.db.rollbackTransaction > Performs a rollback on the given connection. This function is used in **Python Scripting**. ## Description Performs a rollback on the given connection. This will make all statements executed against this transaction since its beginning or since the last commit or rollback undone. If you are done with the transaction, you must also close it after you do a rollback on it. ## Client Permission Restrictions This scripting function has no [Client Permission](ignition-modules\vision\vision-project-properties\vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.db.rollbackTransaction(tx)` ### Parameters Type | Parameter | Description ------- | ------- | ----- String | `tx` | The transaction ID. ### Returns Nothing ### Scope Gateway, Vision Client, Perspective Session ## Code Examples ```python title="Python - Rollback a Transaction on an Exception" # This example uses a for-loop to run multiple queries in a single Transaction, and rollback if an error occurs. # Create some variables for use later. txId = system.db.beginTransaction(timeout=5000) status=2 query = "UPDATE MachineStatus SET status=? WHERE ID=?" errors = False # A flag to denote if we ran into a problem with a query during the transaction. for machineId in range(8): try: system.db.runPrepUpdate(query, args=[status, machineId], tx=txId) except: errors = True break # If we encountered an error... if errors: # ...then rollback the transaction system.db.rollbackTransaction(txId) else: # Otherwise, commit it. system.db.commitTransaction(txId) # In either case, close the transaction when we're done. system.db.closeTransaction(txId) ```