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

Method execute

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

Execute a GQL statement within this transaction Args: statement: GQL statement to execute Raises: TransactionError: If transaction is already finished or execution fails Examples: >>> with session.transaction() as tx:

(self, statement: str)

Source from the content-addressed store, hash-verified

66 raise TransactionError(f"Failed to begin transaction: {e}")
67
68 def execute(self, statement: str) -> None:
69 """
70 Execute a GQL statement within this transaction
71
72 Args:
73 statement: GQL statement to execute
74
75 Raises:
76 TransactionError: If transaction is already finished or execution fails
77
78 Examples:
79 >>> with session.transaction() as tx:
80 ... tx.execute("INSERT (p:Person {name: 'Alice'})")
81 ... tx.execute("INSERT (p:Person {name: 'Bob'})")
82 ... tx.commit()
83 """
84 if self._committed:
85 raise TransactionError("Transaction already committed")
86 if self._rolled_back:
87 raise TransactionError("Transaction already rolled back")
88
89 try:
90 self._session._db.execute(self._session._session_id, statement)
91 except Exception as e:
92 raise TransactionError(f"Execute failed: {e}")
93
94 def query(self, query: str) -> QueryResult:
95 """

Callers 3

__init__Method · 0.45
commitMethod · 0.45
rollbackMethod · 0.45

Calls 1

TransactionErrorClass · 0.85

Tested by

no test coverage detected