MCPcopy Create free account
hub / github.com/BaseXdb/basex / Query

Class Query

basex-api/src/main/python/BaseXClient/BaseXClient.py:256–313  ·  view source on GitHub ↗

class Query. see https://docs.basex.org/wiki/Server_Protocol

Source from the content-addressed store, hash-verified

254
255
256class Query:
257 """class Query.
258
259 see https://docs.basex.org/wiki/Server_Protocol
260 """
261
262 def __init__(self, session, querytxt):
263 """Create query object with session and query"""
264 self.__session = session
265 self.__id = self.__exc(chr(0), querytxt)
266
267 def bind(self, name, value, datatype=''):
268 """Binds a value to a variable.
269An empty string can be specified as data type."""
270 self.__exc(chr(3), self.__id + chr(0) + name + chr(0) + value + chr(0) + datatype)
271
272 def context(self, value, datatype=''):
273 """Bind the context value"""
274 self.__exc(chr(14), self.__id + chr(0) + value + chr(0) + datatype)
275
276 def iter(self):
277 """iterate while the query returns items"""
278 self.__session.send(chr(4) + self.__id)
279 return self.__session.iter_receive()
280
281 def execute(self):
282 """Execute the query and return the result"""
283 return self.__exc(chr(5), self.__id)
284
285 def info(self):
286 """Return query information"""
287 return self.__exc(chr(6), self.__id)
288
289 def options(self):
290 """Return serialization parameters"""
291 return self.__exc(chr(7), self.__id)
292
293 def updating(self):
294 """Returns true if the query may perform updates; false otherwise."""
295 return self.__exc(chr(30), self.__id)
296
297 def full(self):
298 """Returns all resulting items as strings, prefixed by XDM Meta Data."""
299 return self.__exc(chr(31), self.__id)
300
301 def close(self):
302 """Close the query"""
303 self.__exc(chr(2), self.__id)
304
305 def __exc(self, cmd, arg):
306 """internal. don't care."""
307 # should we expose this?
308 # (this makes sense only when mismatch between C/S is existing.)
309 self.__session.send(cmd + arg)
310 result = self.__session.receive()
311 if not self.__session.server_response_success():
312 raise IOError(self.__session.recv_c_str())
313 return result

Callers 1

queryMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected