示例#1
0
    def batch(self):
        """Factory to create a batch for this session.

        :rtype: :class:`~google.cloud.spanner.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)
示例#2
0
 def __enter__(self):
     """Begin ``with`` block."""
     session = self._session = self._database._pool.get()
     batch = self._batch = Batch(session)
     return batch