How to use the bsddb3.db.DBNotFoundError function in bsddb3

To help you get started, we’ve selected a few bsddb3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RDFLib / rdflib / rdflib / plugins / sleepycat.py View on Github external
contexts_value = cspo.get(
            b("^").join([b(""), s, p, o, b("")]), txn=txn) or b("")
        contexts = set(contexts_value.split(b("^")))
        contexts.discard(c)
        contexts_value = b("^").join(contexts)
        for i, _to_key, _from_key in self.__indicies_info:
            i.delete(_to_key((s, p, o), c), txn=txn)
        if not quoted:
            if contexts_value:
                for i, _to_key, _from_key in self.__indicies_info:
                    i.put(_to_key((s, p, o), b("")), contexts_value, txn=txn)
            else:
                for i, _to_key, _from_key in self.__indicies_info:
                    try:
                        i.delete(_to_key((s, p, o), b("")), txn=txn)
                    except db.DBNotFoundError:
                        pass  # TODO: is it okay to ignore these?
github connectIOT / iottoolkit / iottoolkit / rdflib3 / plugins / sleepycat.py View on Github external
cursor = index.cursor(txn=txn)
            try:
                current = cursor.set_range(prefix)
                needs_sync = True
            except db.DBNotFoundError:
                current = None
                needs_sync = False
            cursor.close()
            while current:
                key, value = current
                cursor = index.cursor(txn=txn)
                try:
                    cursor.set_range(key)
                    # Hack to stop 2to3 converting this to next(cursor)
                    current = getattr(cursor, 'next')()
                except db.DBNotFoundError:
                    current = None
                cursor.close()
                if key.startswith(prefix):
                    c, s, p, o = from_key(key)
                    if context is None:
                        contexts_value = index.get(key, txn=txn) or b("")
                        contexts = set(contexts_value.split(b("^"))) # remove triple from all non quoted contexts
                        contexts.add(b("")) # and from the conjunctive index
                        for c in contexts:
                            for i, _to_key, _ in self.__indicies_info:
                                i.delete(_to_key((s, p, o), c), txn=txn)
                    else:
                        self.__remove((s, p, o), c, txn=txn)
                else:
                    break
github RDFLib / rdflib / rdflib / backends / SleepyCat.py View on Github external
def _subject_predicates(self, object, context):
        fromkey = self.fromkey
        tokey = self.tokey        
        if context!=None:
            prefix = "%s" % tokey(context)
            index = self.__cosp
        else:
            prefix = ""
            index = self.__osp            
        prefix += "%s" % tokey(object)
        cursor = index.cursor()
        try:
            current = cursor.set_range(prefix)
        except db.DBNotFoundError:
            current = None
        cursor.close()
        while current:
            key, value = current
            cursor = index.cursor()
            try:
                cursor.set_range(key)
                current = cursor.next()
            except db.DBNotFoundError:
                current = None
            cursor.close()
            if key.startswith(prefix):
                if context!=None:
                    c, o, s, p = split(key)
                else:
                    o, s, p = split(key)
github RDFLib / rdflib / rdflib / store / backends / SleepyCatBacked.py View on Github external
else:
            prefix = ""
            index = self.__spo
        cursor = index.cursor()
        try:
            current = cursor.set_range(prefix)
        except db.DBNotFoundError:
            current = None
        cursor.close()
        while current:
            key, value = current            
            cursor = index.cursor()
            try:
                cursor.set_range(key)
                current = cursor.next()
            except db.DBNotFoundError:
                current = None
            cursor.close()
            if key.startswith(prefix):
                if context!=None:
                    c, s, p, o = split(key)
                else:
                    s, p, o = split(key)
                yield  fromkey(s), fromkey(p), fromkey(o)
            else:
                break
github RDFLib / rdfextras / rdfextras / store / BDBOptimized.py View on Github external
def __all_prefix(self, prefix, index='spoc'):
        next = True
        next_key = prefix
        
        while next:
            c = self.__indices[index].cursor()
            try:
                current = c.set_range(next_key)
                next = c.next()
                if next:
                    next_key, data = next
            except db.DBNotFoundError, e:
                next = None
            # what happens when the cursor is closed and re-opened between
            # each access, does this mean that the lookup will be done again
            # or is the location preserved somehow?
            # in the first case it is better to collect a list of results and
            # then yield over this list
            c.close()
            
            if current:
                key, data = current
                if key and key.startswith(prefix):
                    yield key, data
            
            if next_key and not next_key.startswith(prefix):
                next = None
github zopefoundation / Zope / lib / python / BDBStorage / Autopack.py View on Github external
def _getSerial(self, oid):
        c = self._serials.cursor()
        try:
            lastvalue = None
            # Search for the largest oid+revid key in the serials table that
            # doesn't have a revid component equal to the current revid.
            try:
                rec = c.set_range(oid)
            except db.DBNotFoundError:
                rec = None
            while rec:
                key, value = rec
                koid = key[:8]
                ktid = key[8:]
                if koid <> oid:
                    break
                lastvalue = value
                if ktid == self._serial:
                    break
                rec = c.next()
            if lastvalue is None:
                return None
            return lastvalue[:8]
        finally:
            c.close()
github RDFLib / rdflib / rdflib / plugins / sleepycat.py View on Github external
_from_string = self._from_string
        index, prefix, from_key, results_from_key = self.__lookup((subject, predicate, object), context, txn=txn)

        cursor = index.cursor(txn=txn)
        try:
            current = cursor.set_range(prefix)
        except db.DBNotFoundError:
            current = None
        cursor.close()
        while current:
            key, value = current
            cursor = index.cursor(txn=txn)
            try:
                cursor.set_range(key)
                current = cursor.next()
            except db.DBNotFoundError:
                current = None
            cursor.close()
            if key and key.startswith(prefix):
                contexts_value = index.get(key, txn=txn)
                yield results_from_key(key, subject, predicate, object, contexts_value)
            else:
                break
github RDFLib / rdflib / rdflib / store / BDBOptimized.py View on Github external
def __all_prefix(self, prefix, index='spoc'):
        next = True
        next_key = prefix
        
        while next:
            c = self.__indices[index].cursor()
            try:
                current = c.set_range(next_key)
                next = c.next()
                if next:
                    next_key, data = next
            except db.DBNotFoundError, e:
                next = None
            # what happens when the cursor is closed and re-opened between
            # each access, does this mean that the lookup will be done again 
            # or is the location preserved somehow?
            # in the first case it is better to collect a list of results and
            # then yield over this list
            c.close()
            
            if current:
                key, data = current
                if key and key.startswith(prefix):
                    yield key, data
        
            if next_key and not next_key.startswith(prefix):
                next = None
github coleifer / kvkit / kvkit / backends / berkeleydb.py View on Github external
if start is None:
            key, value = self.last()
        else:
            try:
                key, value = self.set_location(start)
            except DBNotFoundError:
                key, value = self.last()

        if start is None or key <= start:
            yield key, value

        while True:
            try:
                key, value = self.previous()
            except DBNotFoundError:
                raise StopIteration
            else:
                if key < end:
                    raise StopIteration
            yield key, value