Ejemplo n.º 1
0
 def run(self, query, parameters=None, mode=None, bookmarks=None, metadata=None, timeout=None, db=None, **handlers):
     if not parameters:
         parameters = {}
     extra = {}
     if mode in (READ_ACCESS, "r"):
         extra["mode"] = "r"  # It will default to mode "w" if nothing is specified
     if db:
         extra["db"] = db
     if bookmarks:
         try:
             extra["bookmarks"] = list(bookmarks)
         except TypeError:
             raise TypeError("Bookmarks must be provided within an iterable")
     if metadata:
         try:
             extra["tx_metadata"] = dict(metadata)
         except TypeError:
             raise TypeError("Metadata must be coercible to a dict")
     if timeout:
         try:
             extra["tx_timeout"] = int(1000 * timeout)
         except TypeError:
             raise TypeError("Timeout must be specified as a number of seconds")
     fields = (query, parameters, extra)
     log.debug("[#%04X]  C: RUN %s", self.local_port, " ".join(map(repr, fields)))
     if query.upper() == u"COMMIT":
         self._append(b"\x10", fields, CommitResponse(self, **handlers))
     else:
         self._append(b"\x10", fields, Response(self, **handlers))
     self._is_reset = False
Ejemplo n.º 2
0
 def commit(self, **handlers):
     log.debug("[#%04X]  C: COMMIT", self.local_port)
     self._append(b"\x12", (), CommitResponse(self, **handlers))