Drivers

transaction function

A function the driver runs inside a transaction it manages, retrying it when a failure was transient.

Example

A function handed to the driver rather than a transaction opened by hand.

python
def create_person(tx, name, age):
    result = tx.run("""
    CREATE (p:Person {name: $name, age: $age})
    RETURN p
    """, name=name, age=age)

The first argument is always a ManagedTransaction. Any further arguments come from the call to execute_read or execute_write. The driver opens the transaction, runs the function inside it, and commits when the function returns. If the write fails for a transient reason, such as a leader election in a cluster, the driver runs the function again.

Lessons that use this term

The lesson and course links below open in a new tab.

No published lesson uses this term yet.

All glossary terms