Registry / database / leveldb

leveldb

JSON →
library0.201pypypiunverified

This package provides Python bindings for the LevelDB key-value store. It allows Python applications to interact with LevelDB databases for embedded, persistent key-value storage. Note: This specific PyPI package (`leveldb`) is largely unmaintained (last release 2017). Version 0.201. Releases are infrequent to non-existent.

pip install leveldb
INSTALL
IMPORT
SIG · LEVELDB
L
leveldb
databasepythonv0.201
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LevelDB
import leveldb db = leveldb.LevelDB('./path/to/db')
from leveldb import LevelDB
The primary interface is directly from the top-level `leveldb` module, usually instantiated as `leveldb.LevelDB`.

This example demonstrates opening a LevelDB database, putting and getting key-value pairs (which must be bytes), iterating over all entries, and handling missing keys.

import leveldb import os import shutil # Define a temporary database path db_path = './my_temp_leveldb' # Ensure clean slate for demonstration if os.path.exists(db_path): shutil.rmtree(db_path) try: # Open the database, creating it if it doesn't exist # Note: create_if_missing is implicitly True by default db = leveldb.LevelDB(db_path) print(f"Database opened at {db_path}") # Put a key-value pair (keys and values must be bytes) db.Put(b'name', b'Alice') db.Put(b'age', b'30') print("Put: name -> Alice, age -> 30") # Get a value name = db.Get(b'name') print(f"Get 'name': {name.decode('utf-8')}") # Iterate through keys print("All keys in DB:") for key, value in db.RangeIter(): print(f" {key.decode('utf-8')}: {value.decode('utf-8')}") # Try to get a non-existent key (raises KeyError) try: db.Get(b'city') except KeyError: print("Successfully caught KeyError for non-existent key 'city'") finally: # Clean up the database directory if os.path.exists(db_path): shutil.rmtree(db_path) print(f"Cleaned up database at {db_path}")
Debug
Known issues
breakingThis `leveldb` PyPI package is unmaintained (last release 2017) and is known to have compatibility issues with newer Python versions and operating systems. For active development and better support, consider using `plyvel` (https://pypi.org/project/plyvel/), which is an actively maintained alternative.
fix
Migrate to `plyvel`. It offers similar functionality with ongoing maintenance. Installation for `plyvel` is `pip install plyvel`.
affects: <=0.201
gotchaKeys and values *must* be `bytes`. Attempting to use `str` will result in a `TypeError` or unexpected behavior.
fix
Always encode strings to bytes (e.g., `b'my_key'` or `'my_key'.encode('utf-8')`) before passing them to LevelDB methods like `Put` or `Get`.
affects: <=0.201
gotchaRetrieving a non-existent key with `db.Get(key)` will raise a `KeyError`, not return `None`.
fix
Wrap `db.Get(key)` calls in a `try...except KeyError` block, or use an alternative like `plyvel`'s `get(key, default=None)` which provides a more Pythonic default return.
affects: <=0.201
gotchaOnly one process can open a LevelDB database at a time for writes. Attempting to open an already-locked database for writing will result in an error or hang, typically `leveldb.Error`.
fix
Ensure proper resource management, closing database connections when no longer needed. If multiple processes/threads need to access the same DB, consider a separate serialization layer or design your application to use separate DBs.
affects: <=0.201
gotchaRequires the C++ LevelDB library to be installed on the system *before* `pip install leveldb`. Without it, installation will fail with compilation errors.
fix
Install the appropriate `libleveldb-dev` (or equivalent) package for your operating system (e.g., `sudo apt-get install libleveldb-dev` on Debian/Ubuntu, `brew install leveldb` on macOS).
affects: <=0.201
Upgrade
Version history
0.201latest on PyPI · released Dec 9, 2019
Audit
Dependencies
LevelDB C++ LibraryrequiredThis package provides bindings to the LevelDB C++ library, which must be installed on your system. Installation varies by OS (e.g., `sudo apt-get install libleveldb-dev` on Debian/Ubuntu).
Agent activity
9 hits · last 30 days
node
8
Resources