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

Method query

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

Execute a query within this transaction and return results Args: query: GQL query to execute Returns: QueryResult with rows and metadata Raises: TransactionError: If transaction is already finished or query fails Exampl

(self, query: str)

Source from the content-addressed store, hash-verified

92 raise TransactionError(f"Execute failed: {e}")
93
94 def query(self, query: str) -> QueryResult:
95 """
96 Execute a query within this transaction and return results
97
98 Args:
99 query: GQL query to execute
100
101 Returns:
102 QueryResult with rows and metadata
103
104 Raises:
105 TransactionError: If transaction is already finished or query fails
106
107 Examples:
108 >>> with session.transaction() as tx:
109 ... tx.execute("INSERT (p:Person {name: 'Alice', age: 30})")
110 ... result = tx.query("MATCH (p:Person) RETURN p")
111 ... tx.commit()
112 """
113 if self._committed:
114 raise TransactionError("Transaction already committed")
115 if self._rolled_back:
116 raise TransactionError("Transaction already rolled back")
117
118 try:
119 return self._session._db.query(self._session._session_id, query)
120 except Exception as e:
121 raise TransactionError(f"Query failed: {e}")
122
123 def commit(self) -> None:
124 """

Callers

nothing calls this directly

Calls 1

TransactionErrorClass · 0.85

Tested by

no test coverage detected