コード例 #1
0
ファイル: database.py プロジェクト: asthamohta/python-spanner
 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
コード例 #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)
コード例 #3
0
 def __enter__(self):
     """Begin ``with`` block."""
     session = self._session = self._database._pool.get()
     batch = self._batch = Batch(session)
     return batch