Exemplo n.º 1
0
    def __init__(self, database, options):
        ''' Initialize a new instance of the DatabaseIterator.

        :param options: The read options to operate with.
        :param database: The databaes to build an iterator on.
        '''
        self.iterator = LDB.leveldb_create_iterator(database, options)
        if LDB and options: LDB.leveldb_readoptions_destroy(options)
Exemplo n.º 2
0
    def get(self, key, verify_checksum=False, fill_cache=True):
        ''' Delete the supplied value at the given key.

        :param key: The key to delete the value at
        :throws DatabaseException: If an error has occurred
        '''
        result  = None
        options = self.get_read_options(verify_checksum, fill_cache)

        try:
            error = new_native_string()
            size = new_native_size()
            value = LDB.leveldb_get(self.database, options, key, len(key),
                get_reference_to(size), get_reference_to(error))
            self.handle_error(error)
            return as_python_string(value, size)
        finally:
            if LDB and options:
                LDB.leveldb_readoptions_destroy(options)