--- title: "system.db.closeTransaction" description: "Closes the transaction with the given ID." --- # system.db.closeTransaction > Closes the transaction with the given ID. This function is used in **Python Scripting**. ## Description Closes the transaction with the given ID. You must commit or rollback the transaction before you close it. Closing the transaction will return its database connection to the pool. The transaction ID will no longer be valid. ## Client Permission Restrictions This scripting function has [Client Permission](ignition-modules\vision\vision-project-properties\vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.db.closeTransaction(tx)` ### Parameters Type | Parameter | Description ------- | ------- | ----- String | `tx` | The transaction ID. ### Returns Nothing ### Scope Gateway, Vision Client, Perspective Session ## Code Examples ```python title="Running a Query Using Query Transactions" # This example starts a transaction with a 5 second timeout against the project's default database, using the default isolation level. Then it executes a series of update calls, # and commits and closes the transaction. txId = system.db.beginTransaction(timeout=5000) status=2 for machineId in range(8): system.db.runPrepUpdate("UPDATE MachineStatus SET status=? WHERE ID=?", args=[status, machineId], tx=txId) system.db.commitTransaction(txId) system.db.closeTransaction(txId) ```