# How to do the equivalent of system.db.beginTransaction with the sdk

**URL:** <https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578>\
**Category:** Module Development\
**Created:** [January 1, 2022, 10:16pm UTC](https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578 "2022-01-01T22:16:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![james.vosler](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@james.vosler](https://forum.inductiveautomation.com/u/james.vosler)\
**Post date:** [January 1, 2022, 10:16pm UTC](https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578/1 "2022-01-01T22:16:32Z")

</div>

I would like the python programmer to be able to group SQL work done over multiple calls into our own module into a single transaction. Ignition provides system.db.beginTransaction, but I believe the returned transactionId must be used to look up the cached connection, and that transaction will not be available to my module code since it is created in an ignition provided module somewhere. I infer that the beginTransaction call sets the JDBC Connection object’s AutoCommit flag.

Does the SDK provide utility classes to make connection caching and transactions simple, or do we need to create these from scratch?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 1, 2022, 10:25pm UTC](https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578/2 "2022-01-01T22:25:27Z")

</div>

Looks like `DatasourceManager` has relevant methods you can use:

[https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.13/com/inductiveautomation/ignition/gateway/datasource/DatasourceManager.html](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.13/com/inductiveautomation/ignition/gateway/datasource/DatasourceManager.html)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 1, 2022, 10:39pm UTC](https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578/3 "2022-01-01T22:39:18Z")

</div>

> [@james.vosler](#):
>
> beginTransaction call sets the JDBC Connection object’s AutoCommit flag

I would expect the opposite, actually.

---

<div class="post-metadata">

**Author:** ![james.vosler](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@james.vosler](https://forum.inductiveautomation.com/u/james.vosler)\
**Post date:** [January 4, 2022, 9:03pm UTC](https://forum.inductiveautomation.com/t/how-to-do-the-equivalent-of-system-db-begintransaction-with-the-sdk/54578/4 "2022-01-04T21:03:08Z")

</div>

Correct - by default the auto-commit flag is set, so to do a transaction one must turn it off by calling setAutoCommit(false).
