Skip to main content

An AsyncIO bridge for DBM.

Project description

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

  • Shared single thread implementation for best asyncio performance

  • Typing support

  • Docstrings and documentation

  • Fully tested

Why use DBM?

DBM is a fast, 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 popular embedded database support by Python’s standard library - it can be significantly faster, but also does not provide any of sqlite’s advanced features like transactions or process safety. [3]

If you are are looking for a simple and fast key-value store (e.g. for caching) - especially on Linux systems, where the GDBM variant is available - DBM can be a good solution.

Caveats

While Python’s DBM library should ensure, that aiodbm works with any DBM variant and on any system, this library has been developed and tested primarily with GDBM on Linux. On non Linux-like systems Python might use it’s “dumb” DBM implementation, which will be much slower.

DBM 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 queue:

import asyncio

import aiodbm


async def main():
    async with aiodbm.open("example.dbm", "c") as db:  # opening/creating database
        await db.set("alpha", "green")  # creating new key alpha with value green
        value = await db.get("alpha")  # fetching value for key alpha
        print(value)
        await db.delete("alpha")  # delete key alpha


asyncio.run(main())

Installation

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

pip install aiodbm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiodbm-0.2.0b1.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

aiodbm-0.2.0b1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page