Skip to main content

asyncio drivers for FoundationDB

Project description

asyncio-foundationdb

early draft

asyncio drivers for foundationdb tested with CPython 3.9 and PyPy 3.7

Library Database

Table of Content

Getting started

pip install asyncio-foundationdb
import found


async def get(tx, key):
    out = await found.get(tx, key)

async def set(tx, key, value):
    return found.set(tx, key, value)


db = await found.open()
out = await found.transactional(db, get, b'hello')
assert out is None

await found.transactional(db, set, b'hello', b'world')
out = await found.transactional(db, get, b'hello')
assert out == b'world'

ChangeLog

v0.10.x

  • Almost full rewrite
  • Remove hooks for the time being
  • Port Generic Tuple Store aka. nstore
  • Add blob store aka. bstore
  • Add Entity-Attribute-Value store aka. eavstore
  • Add inverted index store aka. pstore

import found

found.BaseFoundException

All found exceptions inherit that class.

found.FoundException

Exception raised when there is an error foundationdb client driver, or foundationdb server side.

async found.open(cluster_file=None)

Open database.

Coroutine that will open a connection with the cluster specified in the file cluster_file. If cluster_file is not provided the default is /etc/foundationdb/fdb.cluster. Returns a database object.

async found.transactional(db, func, *args, snapshot=False, **kwargs)

Operate a transaction for func.

Coroutine that will operate a transaction against db for func. If snapshot=True then the transaction is read-only. func will receive an appropriate transaction object as first argument, then args, then kwargs. Because of errors transactional might run func several times, hence func should be idempotent.

async found.get(tx, key)

Get the value associated with key.

Coroutine that will fetch the value associated with key inside the database associated with tx. key must be bytes. In case of success, returns bytes. Otherwise, if there is no value associated with key, returns the object None.

found.set(tx, key, value)

Set key to value.

In the database associated with tx, associate key with value. Both key and value must be bytes.

found.pack(tuple)

Serialize python objects tuple into bytes.

found.pack_with_versionstamp(tuple)

Serialize python objects tuple into bytes. tuple may contain found.Versionstamp objects.

found.unpack(bytes)

Deserialize bytes into python objects.

found.Versionstamp(...)

FIXME.

found.clear(tx, key, other=None)

Remove key or keys.

In the database associated with tx, clear the specified key or range of keys.

key and other if provided must be bytes.

If other=None, then clear the association that might exists with key. Otherwise, if other is provided, found.clear will remove any association between key and other but not the association with other if any (that is other is excluded from the range).

async found.query(tx, key, other, *, limit=0, mode=STREAMING_MODE_ITERATOR)

Fetch key-value pairs.

In the database associated with tx, generate at most limit key-value pairs inside the specified range, with the specified order.

If key < other then found.query generates key-value pairs in lexicographic order. Otherwise, if key > other then found.query generates key-value pairs in reverse lexicographic order, that is starting at other until key.

If limit=0, then found.query generates all key-value pairs in the specified bounds. Otherwise if limit > 0 then, it generates at most limit pairs.

The keyword mode can be one the following constant:

  • found.STREAMING_MODE_WANT_ALL
  • found.STREAMING_MODE_ITERATOR
  • found.STREAMING_MODE_EXACT
  • found.STREAMING_MODE_SMALL
  • found.STREAMING_MODE_MEDIUM
  • found.STREAMING_MODE_LARGE
  • found.STREAMING_MODE_SERIAL

found.next_prefix(key)

Returns the immediatly next byte sequence that is not prefix of key.

found.lt(key, offset=0)

found.lte(key, offset=0)

found.gt(key, offset=0)

found.gte(key, offset=0)

async found.read_version(tx)

found.set_read_version(tx, version)

found.add(tx, key, param)

found.bit_and(tx, key, param)

found.bit_or(tx, key, param)

found.bit_xor(tx, key, param)

found.max(tx, key, param)

found.byte_max(tx, key, param)

found.min(tx, key, param)

found.byte_min(tx, key, param)

found.set_versionstamped_key(tx, key, param)

found.set_versionstamped_value(tx, key, param)

from found import bstore

bstore.BStoreException

Exception specific to bstore.

bstore.make(name, prefix)

Handle over a bstore called name with prefix.

async bstore.get_or_create(tx, bstore, blob)

bstore.get(tx, bstore, uid)

from found import nstore

nstore.NStoreException

Exception specific to nstore.

nstore.make(name, prefix, n)

Create a handle over a nstore called name with prefix and n columns.

The argument name should be a string, it is really meant to ease debugging. prefix should be a tuple that can be packed with found.pack. Last but not least, n is the number of columns in the returned tuple store (or, if you prefer, the number of tuple items).

It is preferable to store the returned value.

nstore.add(tx, nstore, *items, *, value=b'')

In the database associated with tx, as part of nstore, add items associated with value.

nstore.remove(tx, nstore, *items)

In the database associated with tx, as part of nstore, remove items and the associated value.

async nstore.get(tx, nstore, *items)

In the database associated with tx, as part of nstore, get the value associated with items. If there is no such items in nstore, returns None.

nstore.var(name)

Create a variable called name for use with nstore.query.

async nstore.query(tx, nstore, pattern, *patterns)

In the database associated with tx, as part of nstore, generate mappings that match pattern and patterns. Both pattern and patterns may contain nstore.var that will be replaced with matching values in the generic tuple store.

from found import eavstore

eavstore.make(name, prefix)

Create a handle over an eavstore called name with prefix.

The argument name should be a string, it is really meant to ease debugging. prefix should be a tuple that can be packed with found.pack.

eavstore.create(tx, eavstore, dict)

Store a dictionary.

In the database associated with tx, as part of eavstore, save dict and returns its unique identifier.

async eavstore.get(tx, eavstore, uid)

Fetch a dictionary.

In the database associated with tx, as part of eavstore, retrieve the dictionary associated with uid. If there is no such dictionary, returns an empty dictionary.

eavstore.remove(tx, eavstore, uid)

Clear a dictionary.

In the database associated with tx, as part of eavstore, remove the dictionary associated with uid.

eavstore.update(tx, eavstore, uid, dict)

Update a dictionary.

In the database associated with tx, as part of eavstore, replace the dictionary associated with uid with dict.

async eavstore.query(tx, eavstore, key, value)

Lookup dictionaries according to sppecification.

In the database associated with tx, as part of eavstore, generates unique identifier for dictionaries that have key equal to value.

from found import pstore

pstore.PStoreException

Exception specific to pstore.

pstore.make(name, prefix, pool)

A handle over a pstore called name with prefix, that will use pool.

async pstore.index(tx, store, docuid, counter)

Associates docuid with counter.

Coroutine that associates the identifier docuid with the dict-like counter inside the database associated with tx at store for later retriaval with pstore.search.

counter must be a dict-like mapping string to integers bigger than zero.

async pstore.search(tx, store, keywords, limit)

Return a sorted list of at most limit documents matching keywords.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_35_x86_64.whl (63.3 kB view details)

Uploaded PyPy manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_31_x86_64.whl (63.3 kB view details)

Uploaded PyPy manylinux: glibc 2.31+ x86-64

asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_35_x86_64.whl (51.5 kB view details)

Uploaded PyPy manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_31_x86_64.whl (51.4 kB view details)

Uploaded PyPy manylinux: glibc 2.31+ x86-64

asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_35_x86_64.whl (371.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_31_x86_64.whl (386.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ x86-64

asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_35_x86_64.whl (294.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_31_x86_64.whl (306.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ x86-64

asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_35_x86_64.whl (217.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_31_x86_64.whl (225.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.31+ x86-64

asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_35_x86_64.whl (140.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.35+ x86-64

asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_31_x86_64.whl (143.8 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.31+ x86-64

File details

Details for the file asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 92c413cdc62bbde5103081b2d0236e39da2e7f02e86114018bb33e5caa6c3dc3
MD5 10bbc82888264503b28774a8230f40b5
BLAKE2b-256 b8122cd8a2bed881a4c561e79aa080187948c68d2628345aa804b5a81223f6d3

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-pp38-pypy38_pp73-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 076e4e2b44c149192d3d58619f361f86af7930e54daca7a31ede084521baf72a
MD5 bc4659449c97a6433059688a6094eb50
BLAKE2b-256 811104fa0bf8152164cfa203d6fc39de5740ce0f1b1d0633f6097d9fd8e9d824

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 8c3476b693a588b7f27a68f762b674d9ce3775db95880b08ded33396e9b3bd13
MD5 cab47a8e75ec8f961caf46517fd0472f
BLAKE2b-256 9fae1155c2add5f6822a4e4122128392715052a1bb5dbb0c11c6aa544b5a8ce7

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-pp37-pypy37_pp73-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 73452eda97dfff34deee8bb305c8279d71801098b5809aacf2f08d1b17da83cd
MD5 5b462b57e95727a6cdf309717445ae87
BLAKE2b-256 9da3f9f516422f7c5f63a14b41568de15a97a0b4313075dfe81c9734fc189cba

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 e135381268277b6ca05a5881e49e2f156f8ba6b96cbbead5783453e4c39bdb42
MD5 53443701d54d8167beb5a0648b364b20
BLAKE2b-256 2982697559a357c51e2a1202c758dfd788e45b41abd80a676e10c00dad16c527

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 eea1f36d4ce0ca2a8efe1ca34252e7caf9d9e2c5c19d0ee5dbf3abfe1a7c3d1f
MD5 86231d5fc492e74d6cf14bd3161a11c5
BLAKE2b-256 9ad331247fd132164b42f335d2212c318cebfcd76b592f56a2d91d6b5568ec89

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 ec0bc625750ff437308b83df86822925098dc670542cc7a656ff40e59c33bf05
MD5 d110c6204ba240fadc8fddd8817f98a9
BLAKE2b-256 8508e0786aa99528d3751a7610d37704cc308c8346f8459f04299ab3f1af9513

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 146e6cf5dc50d17f2d45d25ba2bf0ec6ca5dcbbcf610ec97a40f475652c5fbe7
MD5 6bc91542c4df4f2e3af0a9f3f6f037f0
BLAKE2b-256 8210cc5cc5287e207549a059a3115f822cff0c178c274e5335a1290d737c78d0

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 cdcb549a8a10717790c47b0b76e2ccf422688897db3304d5d77203f515b78eca
MD5 6c8dadc40cb10cad99bddf8611f86be7
BLAKE2b-256 5e779e809160b205e092f7e04b39d279b2f4d532a090a5c98b343e42cef50eb4

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 d242a89ebb0a579d37043f2caf20f372a819e9c49517610586992dc7149e3b04
MD5 5c97dd15c9246f197d84ddbe1b9b3031
BLAKE2b-256 f67a12417ae570b3d440bb80e205dfbe38735c4e62a40a01e9e330b005db1074

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 11ee0ee78e4bfb90dd44e775dee8908ec97d4bb51227b9a148f9d016023d0848
MD5 2c5611af4a26986fd62fa1a9d925dabe
BLAKE2b-256 f92a21c5d62e2f32726ab0c7cfc763d2295d2fe2f27de8041ef7bec31044dc56

See more details on using hashes here.

File details

Details for the file asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for asyncio_foundationdb-0.10.4-cp37-cp37m-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 04866c31be59b9fc223f1e3a7ba447b43fb7f609b1df439096905c619f8e34c9
MD5 a2b8c3ea86a5cc6ef47c4bfe1d19b415
BLAKE2b-256 629ccf27e8890d7f79ceebc15e9c20617abb83bcb6771d05ccc5b94c6699e9fe

See more details on using hashes here.

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