def __init__(self): self._dc = None try: self._dc = sdb.create_dc() except SystemError: raise SDBBaseError("Failed to alloc data center object", const.SDB_OOM)
def __init__(self): """constructor of cursor Exceptions: pysequoiadb.error.SDBBaseError """ self._cursor = None try: self._cursor = sdb.create_cursor() except SystemError: raise SDBBaseError("Failed to alloc cursor", const.SDB_OOM)
def __init__(self): """invoked when a new object is producted. Exceptions: pysequoiadb.error.SDBBaseError """ #'cs' is short for collection space try: self._cs = sdb.create_cs() except SystemError: raise SDBBaseError("Failed to alloc collection space", const.SDB_OOM)
def __init__(self, client): """constructor of replica node Exceptions: pysequoiadb.error.SDBBaseError """ self._client = client try: self._node = sdb.create_node() except SystemError: raise SDBBaseError("Failed to alloc node", const.SDB_OOM)
def next(self): """Return the next document of current cursor, and move forward. Return values: a dict object of record Exceptions: pysequoiadb.error.SDBBaseError pysequoiadb.error.SDBEndOfCursor """ try: rc, bson_string = sdb.cr_next(self._cursor) if const.SDB_OK != rc: if const.SDB_DMS_EOC == rc: raise SDBEndOfCursor else: raise SDBBaseError("Failed to get next record", rc) else: record, size = bson._bson_to_dict(bson_string, dict, False, bson.OLD_UUID_SUBTYPE, True) except SDBBaseError: raise return record