FoundationDB drivers for asyncio
Project description
asyncio-foundationdb
FoundationDB drivers for asyncio tested with CPython, and PyPy 3.8+.
Marketing
In the fast-paced digital landscape, FoundationDB is the unsung hero of data management. That Key-Value Store serve as the backbone of countless applications, providing lightning-fast access to essential information. With its simple yet powerful structure, FoundationDB effortlessly organizes and retrieve data, making it the go-to choice for developers seeking speed and efficiency. Whether you're building a dynamic web application, a datalake knowledge base, a robust caching system, or a real-time analytics platform, FoundationDB is your trusty ally, ensuring seamless data access and enabling innovation at the speed of thought. Discover the key to data-driven success with FoundationDB – where simplicity meets scalability, and speed meets reliability
- Getting started
- ChangeLog
import found
from found import bstore
from found import nstore
from found import eavstore
from found import pstore
from found import vnstore
Enter the world of data organization and retrieval with FoundationDB, the Ordered Key-Value Store. FoundationDB is your solution for maintaining structured data in a way that preserves both order and simplicity. With the power to efficiently sort and access data, FoundationDB is a versatile tool for a wide range of applications. From managing time-series data in financial systems, or hierarchies, to optimizing search functionality in e-commerce platforms, FoundationDB offers an elegant and reliable solution. Take control of your data, embrace order, and unlock a new level of efficiency with FoundationDB - where data is not just stored, but intelligently organized for streamlined success.
FoundationDB, the bedrock of modern data infrastructure, is the groundbreaking distributed database system that unlocks new frontiers in reliability, scalability, and performance. With a unique combination of ACID transactions, distributed architecture, and a highly versatile data model, FoundationDB seamlessly handles complex workloads while ensuring data integrity. It's the go-to choice for organizations seeking a solid foundation for mission-critical applications, from e-commerce platforms to cutting-edge IoT ecosystems. Harness the power of FoundationDB and experience a world where your data is always available, always consistent, and always ready to fuel your boldest innovations.
Build on a solid foundation with FoundationDB.
Installation
In a minute, install foundationdb, getting the latest stable release from the official release page: https://github.com/apple/foundationdb/releases
Then install asyncio drivers asyncio-foundationdb
:
pip install asyncio-foundationdb
Example
async def readme():
async def get(tx, key):
out = await found.get(tx, key)
return out
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'
await found.transactional(db, set, b'azul', b'world')
out = await found.transactional(db, get, b'azul')
assert out == b'world'
async def query(tx, key, other):
out = await found.all(found.query(tx, key, other))
return out
out = await found.transactional(db, query, b'', b'\xFF')
assert [(b'azul', b'world'), (b'hello', b'world')]
asyncio.run(readme())
ChangeLog
v0.12.0
- Move back to GitHub;
- Add versioned generic tuple store (code name
vnstore
)
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.
await 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.
await 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.
await 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
.
await 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.
await 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).
await 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)
await 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
.
await bstore.get_or_create(tx, bstore, blob)
await 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.
await nstore.add(tx, nstore, *items, *, value=b'')
In the database associated with tx
, as part of nstore
, add
items
associated with value
.
await nstore.remove(tx, nstore, *items)
In the database associated with tx
, as part of nstore
, remove
items
and the associated value.
await 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
.
await 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
.
await 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.
await 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.
await eavstore.remove(tx, eavstore, uid)
Clear a dictionary.
In the database associated with tx
, as part of eavstore
, remove
the dictionary associated with uid
.
await 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
.
await 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
.
await 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.
await pstore.search(tx, store, keywords, limit)
Return a sorted list of at most limit
documents matching keywords
.
from found import vnstore
vnstore.make(name, prefix, items)
Create a handle over a vnstore
called name
with the prefix tuple
prefix
, and items
as column names.
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, items
is the columns in the returned
tuple store (or, if you prefer, the name of tuple items).
It is preferable to store the returned value.
await vnstore.change_create(tr, vnstore)
Return the unique idenifier of a new change in database. Its initial
signifiance is None
which means it is invisible to other
transactions, and its message None
.
vnstore.change_continue(tr, vsntore, changeid)
Against transaction tr
, and vnstore
, continue a change changeid
.
await vnstore.change_message(tr, vnstore, changeid, message)
Replace the exisiting message of changeid
with message
await vnstore.change_appply(tr, vnstore, changeid)
Apply the change changeid
against vnstore
, setting the next
uuid7
as significance.
Known issue: No serializability guarantee, because of write skew anomaly
-
The historization of data introduce a risk of inexact serializability. This can break things when changes happen over overlapping triples. Strict ordering, serializability is not guaranteed, hence one transaction may write, a value based on a value that was overwritten by another concurrent change also known as a write skew anomaly.
-
The use
uuid7
can break consistency, when deleting the same triple, and adding another, it may result in two deletion, and two additions, that may break the schema, and application relying on vnstore.
In other words, as long as we rely uuid7
we can't consider
transaction commited with vnstore_change_apply
happen as if all
transaction were commited after the other, that is, there is no
serializability guarantee.
There is several ways to workaround some of those issues, they require more code. Contact me for more info.
await vnstore.ask(tr, vnstore, *items)
Return True
if items
is alive in the space vnstore
.
await vnstore.remove(tr, vnstore, *items)
Remove items
from vnstore
.
await vnstore.query(tr, vnstore, pattern, *pattern)
Return immutable mappings where vnstore.var
from pattern
, and
patterns
are replaced with objects from vnstore
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file asyncio_foundationdb-0.12.0.tar.gz
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2250c45ac023a66ff6c63dd0f25e04782612ea7723845d4d4f9996ec3935789a |
|
MD5 | 362bd663c70f157aadf24eacbbc20a67 |
|
BLAKE2b-256 | 66874a5ed599f774edc8c8641326a5c02d2c5429c1c70291ad47356c955a8222 |
File details
Details for the file asyncio_foundationdb-0.12.0-pp310-pypy310_pp73-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-pp310-pypy310_pp73-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: PyPy, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 PyPy/7.3.15 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d4e0815c089287e5282dd86bf1cbb38b3510e6159ebd823c5a6a91ed8660632 |
|
MD5 | d3d0534cb4971187bfb74edde1760a1c |
|
BLAKE2b-256 | eb955184b1679673d4f10e0488bed1fb11ebce4ab78a27d318401cbe5fee189e |
File details
Details for the file asyncio_foundationdb-0.12.0-pp39-pypy39_pp73-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-pp39-pypy39_pp73-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: PyPy, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 PyPy/7.3.15 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cd59fa403029c2873cf13984fbf0ffeb62bb1bb6fd7db16aa57b16320f9950d |
|
MD5 | bbf55b967e9bfed7a98ab4697f8c666b |
|
BLAKE2b-256 | d53a031d127484ff7729894c4ad94673c2302c963b4a86b41aefef928b736bbd |
File details
Details for the file asyncio_foundationdb-0.12.0-pp38-pypy38_pp73-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-pp38-pypy38_pp73-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: PyPy, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 PyPy/7.3.11 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e06da7731c79f554b532c429ef6935fe85496fe5f9fb1060d2a4ac47643697b0 |
|
MD5 | aa873fbe5e80e3fdf4442053c7bbe79a |
|
BLAKE2b-256 | da6c8186dcaa044e02385b557652ffe24c455a1a7d055ac2f2d811c19b5a1570 |
File details
Details for the file asyncio_foundationdb-0.12.0-cp312-cp312-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-cp312-cp312-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28c4621cdc896d77e9eda43885fb7c76cb422e600f83c7945b41cdb90ecf8280 |
|
MD5 | 5d8b3dd1d02aa43f963190e8effa0ac7 |
|
BLAKE2b-256 | 12f2e71d531ee14f0588e1fffe6c3b7a18f779476ac3ac17b9bb2aa8c33f9bf5 |
File details
Details for the file asyncio_foundationdb-0.12.0-cp311-cp311-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-cp311-cp311-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f65680ecc12dc54b5a3a5402ea075e09732a79aa0e8f4a5b493668be02e6dfa |
|
MD5 | 9230008759bc0ced03e653b31e2d9746 |
|
BLAKE2b-256 | 9127b131c4ec2f587fd6e2d7c0890ad70b700b636e6fecaa2a0eb75fedb03578 |
File details
Details for the file asyncio_foundationdb-0.12.0-cp310-cp310-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-cp310-cp310-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.14 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2028b9646b6abf22c3855aab923c8285f7dc4ca451b09ca35b2c9ba9ba660c99 |
|
MD5 | 956ec4fd3e2a2bc7c6f43cd6f6ba3258 |
|
BLAKE2b-256 | caf52e0f754e7a06553b8a12f37607c7672315e18e9df6e922a5b49566f2b142 |
File details
Details for the file asyncio_foundationdb-0.12.0-cp39-cp39-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-cp39-cp39-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.9, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.19 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ef5c4e1d853652000e6e00381104b82b9b70a69ac8b91f1def33ca11c104a6b |
|
MD5 | 5dccb833f5d442bfccee1ee22c4ccea2 |
|
BLAKE2b-256 | 5236d7c113b7b71b985a254bca98fa8e4e55637362951dd8a85b6f254fcc5dfa |
File details
Details for the file asyncio_foundationdb-0.12.0-cp38-cp38-manylinux_2_35_x86_64.whl
.
File metadata
- Download URL: asyncio_foundationdb-0.12.0-cp38-cp38-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 61.5 kB
- Tags: CPython 3.8, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 151eefa49581b4a10ce0a35044b9a84f973c8f7b8f1c8b7035809c827e1f2428 |
|
MD5 | 4fc36ab11a09eb2a7a866e0a0bff11ef |
|
BLAKE2b-256 | 6bd7d64b36b1346bcacec778df931d7f5cd7a2b5bdfd656258668d2d18690c33 |