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

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?

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

1 Like

I would expect the opposite, actually.

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