MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / commit

Method commit

sdk-python/src/graphlite_sdk/transaction.py:123–147  ·  view source on GitHub ↗

Commit the transaction Persists all changes made within this transaction. After calling commit(), the transaction cannot be used further. Raises: TransactionError: If transaction is already finished or commit fails Examples: >>> wit

(self)

Source from the content-addressed store, hash-verified

121 raise TransactionError(f"Query failed: {e}")
122
123 def commit(self) -> None:
124 """
125 Commit the transaction
126
127 Persists all changes made within this transaction. After calling commit(),
128 the transaction cannot be used further.
129
130 Raises:
131 TransactionError: If transaction is already finished or commit fails
132
133 Examples:
134 >>> with session.transaction() as tx:
135 ... tx.execute("INSERT (p:Person {name: 'Alice'})")
136 ... tx.commit() # Changes are now persistent
137 """
138 if self._committed:
139 raise TransactionError("Transaction already committed")
140 if self._rolled_back:
141 raise TransactionError("Transaction already rolled back")
142
143 try:
144 self._session._db.execute(self._session._session_id, "COMMIT")
145 self._committed = True
146 except Exception as e:
147 raise TransactionError(f"Failed to commit: {e}")
148
149 def rollback(self) -> None:
150 """

Callers 2

mainFunction · 0.45

Calls 2

TransactionErrorClass · 0.85
executeMethod · 0.45

Tested by

no test coverage detected