How to use the lmdb.Cursor function in lmdb

To help you get started, we’ve selected a few lmdb 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 eavatar / eavatar-me / src / ava / data / engine.py View on Github external
def __init__(self, _txn, _db, _readonly=True):

        self._txn = _txn
        self._db = _db
        self._readonly = _readonly
        self._cursor = lmdb.Cursor(_db, _txn)
github oddjobz / pynndb / pynndb / table.py View on Github external
:param name: The name of the index to reindex
        :type name: str
        :param txn: An open transaction
        :type txn: Transaction
        :return: Number of index entries created
        :rtype: int
        """
        if name not in self._indexes: raise xIndexMissing
        index = self._indexes[name]

        with self.begin() as transaction:
            txn = txn if txn else transaction
            count = 0
            self._indexes[name].empty(txn)

            with lmdb.Cursor(self._db, txn) as cursor:
                if cursor.first():
                    while True:
                        record = loads(cursor.value().decode())
                        if index.put(txn, cursor.key().decode(), record):
                            count += 1
                        if not cursor.next():
                            break
            return count
github oddjobz / pynndb / pynndb / database.py View on Github external
def tables():
            result = []
            with lmdb.Cursor(self._db, txn) as cursor:
                if cursor.first():
                    while True:
                        name = cursor.key().decode()
                        if all or name[0] not in ['_', '~']:
                            result.append(name)
                        if not cursor.next():
                            break
            return result
github oddjobz / pynndb / pynndb / index.py View on Github external
def cursor(self, txn=None):
        """
        Return a cursor into the current index

        :param txn: Is an open Transaction
        :type txn: Transaction
        :return: An active Cursor object
        :rtype: Cursor
        """
        return lmdb.Cursor(self._db, txn)