system.db.rollbackTransaction in common queries

Hi guys,
I have a quick question,

When executing a SQL transaction, that is, grouping several queries, we can use the command “system.db.rollbackTransaction (txId)” in case of failure.
My question is, in queries that are not transaction type, what happens when they fail?? Rollback is done automatically?? Or is it recommended to also add the rollback command in case of queries that are extensive or prone to failure??

-----------------------------SQL TRANSACTION EXAMPLE
# This example will use 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)
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): 
        system.db.runPrepUpdate(query,  args=[status, machineId], tx=txId)     
        errors = True  
# If we encountered an error...
if errors:
    # ...then rollback the transaction
    # Otherwise, commit it
# In either case, close the transaction when we're done.

-----------------------------SQL QUERY EXAMPLE
query = "INSERT INTO orders (account_id, product_name) VALUES (%i, '%s')" % (123, "Bananas")

Much thanks!

If you’re only running a single query, there’s no reason to use a transaction. An error being thrown means that either A: something was wrong with the script itself, so Ignition never attempted to send the query to the database, or B: the database rejected your statement, usually with some kind of error message or explanation. In the latter case, there’s nothing to roll back, because the statement never worked in the first place.

Transactions are most useful when you have potentially tens/hundreds of statements to issue together, and you want them to be ‘atomic’ - so that if one record among the collection has a problem, none of the records are inserted. Imagine trying to insert 1000 user records, then getting an error, but 999 of the records did insert. Now you’ve got to find the record that failed, as well as repeat the operation.