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)
def __enter__(self): """Begin ``with`` block.""" session = self._session = self._database._pool.get() batch = self._batch = Batch(session) return batch