Skip to main content

aiodbm: DBM for AsyncIO

An AsyncIO bridge for Python’s DBM library.

release python tests codecov docs pre-commit Code style: black

Description

aiodbm is a library that allows you to use DBM in asyncio code.

  • Full coverage of Python’s DBM and GDBM API

  • Typing support

  • Docstrings and documentation

  • Fully tested

Why use aiodbm?

DBM is a fast and easy to use, embedded key-value store. It is supported by Python’s standard library [1] and can be used on most systems without requiring additional dependencies [2].

Compared to Sqlite - the other embedded database supported by Python’s standard library - it is significantly faster when used as key/value store.

In our measurements we see that aiodbm is hundreds or times faster for writes and more then three faster for reads compared to aiosqlite [3]:

Throughput measurements for aiodbm vs. aiosqlite

So if you are on a Linux system and need a fast and an easy to use embedded key-value store for asyncio, aiodbm can be a good solution.

Caveats

On non Linux-like systems DBM is usually not available and Python will fall back on it’s “dumb” DBM implementation. While DBM’s core functionality still works, that implementation is be much slower.

Python’s DBM library is not process safe. If you need a key-value store in a multi process context (e.g. a web server running with gunicorn) we’d recommend to use Redis or something similar instead.

Usage

Here is a basic example on how to use the library:

import asyncio

import aiodbm


async def main():
   # opening/creating database
   async with aiodbm.open("example.dbm", "c") as db:

      # creating new key alpha with value green
      await db.set("alpha", "green")

      # fetching value for key alpha
      value = await db.get("alpha")
      print(value)

      # delete key alpha
      await db.delete("alpha")


asyncio.run(main())

Installation

You can install this library directly from PyPI with the following command:

pip install aiodbm

Reference

Metadata

Release files for aiodbm 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiodbm 0.4.2
File Size Uploaded
aiodbm-0.4.2.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiodbm 0.4.2
File Interpreter ABI Platform
aiodbm-0.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / aiodbm-0.4.2.tar.gz

Download URL aiodbm-0.4.2.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b59f270ca509fc4edf630f5310666bb51a9308b787235d37d60cf522daedaf2f
BLAKE2b-256 checksum
How to use checksums
bd64a630bf3500dfe2660d80539d8f5d73adc56bfb84fec2e9dac730a4125bf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / aiodbm-0.4.2-py3-none-any.whl

Download URL aiodbm-0.4.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
423bb51519d0e16ac2c12e52331afef99b073c6f424329402b6498e687721000
BLAKE2b-256 checksum
How to use checksums
92969c24381069bd997106adf3f0374542642a96f2fac7546108e5391c34a52b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page