Exemplo n.º 1
0
 def __enter__(self):
     """Begin ``with`` block."""
     session = self._session = self._database._pool.get()
     batch = self._batch = Batch(session)
     if self._request_options.transaction_tag:
         batch.transaction_tag = self._request_options.transaction_tag
     return batch
Exemplo n.º 2
0
    def batch(self):
        """Factory to create a batch for this session.

        :rtype: :class:`~google.cloud.spanner_v1.batch.Batch`
        :returns: a batch bound to this session
        :raises ValueError: if the session has not yet been created.
        """
        if self._session_id is None:
            raise ValueError("Session has not been created.")

        return Batch(self)
Exemplo n.º 3
0
 def __enter__(self):
     """Begin ``with`` block."""
     session = self._session = self._database._pool.get()
     batch = self._batch = Batch(session)
     return batch