Package: asyncio-foundationdb
asyncio-foundationdbasyncio drivers for foundationdb tested with CPython 3.7-3.10 and PyPy 3.7, and PyPy 3.8Table of ContentGetting startedChangeLogv0.10.ximport foundfrom found import bstorefrom found import nstorefrom found import eavstorefrom found import pstoreGetting startedpip install asyncio-foundationdbimportfoundasyncdefget(tx,key):out=awaitfound.get(tx,key)asyncdefset(tx,key,value):returnfound.set(tx,key,value)db=awaitfound.open()out=awaitfound.transactional(db,get,b'hello')assertoutisNoneawaitfound.transactional(db,set,b'hello',b'world')out=awaitfound.transactional(db,get,b'hello')assertout==b'world'ChangeLogv0.10.xAlmost full rewriteRemove hooks for the time beingPort Generic Tuple Store aka.nstoreAdd blob store aka.bstoreAdd Entity-Attribute-Value store aka.eavstoreAdd inverted index store aka.pstoreimport foundfound.BaseFoundExceptionAllfoundexceptions inherit that class.found.FoundExceptionException raised when there is an error foundationdb client driver, or
foundationdb server side.asyncfound.open(cluster_file=None)Open database.Coroutine that will open a connection with the cluster specified in
the filecluster_file. Ifcluster_fileis not provided the default
is/etc/foundationdb/fdb.cluster. Returns a database object.asyncfound.transactional(db, func, *args, snapshot=False, **kwargs)Operate a transaction forfunc.Coroutine that will operate a transaction againstdbforfunc. Ifsnapshot=Truethen the transaction is read-only.funcwill receive
an appropriate transaction object as first argument, thenargs, thenkwargs. Because of errorstransactionalmight runfuncseveral
times, hencefuncshould be idempotent.asyncfound.get(tx, key)Get the value associated withkey.Coroutine that will fetch the value associated withkeyinside the
database associated withtx.keymust bebytes. In case of
success, returnsbytes. Otherwise, if there is no value associated
withkey, returns the objectNone.found.set(tx, key, value)Setkeytovalue.In the database associated withtx, associatekeywithvalue. Bothkeyandvaluemust bebytes.found.pack(tuple)Serialize python objectstupleinto bytes.found.pack_with_versionstamp(tuple)Serialize python objectstupleinto bytes.tuplemay containfound.Versionstampobjects.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 withtx, clear the specifiedkeyor
range of keys.keyandotherif provided must bebytes.Ifother=None, then clear the association that might exists withkey. Otherwise, ifotheris provided,found.clearwill remove
any association betweenkeyandotherbut not the association withotherif any (that isotheris excluded from the range).asyncfound.query(tx, key, other, *, limit=0, mode=STREAMING_MODE_ITERATOR)Fetch key-value pairs.In the database associated withtx, generate at mostlimitkey-value pairs inside the specified range, with the specified order.Ifkey < otherthenfound.querygenerates key-value pairs in
lexicographic order. Otherwise, ifkey > otherthenfound.querygenerates key-value pairs in reverse lexicographic order, that is
starting atotheruntilkey.Iflimit=0, thenfound.querygenerates all key-value pairs in the
specified bounds. Otherwise iflimit > 0then, it generates at mostlimitpairs.The keywordmodecan be one the following constant:found.STREAMING_MODE_WANT_ALLfound.STREAMING_MODE_ITERATORfound.STREAMING_MODE_EXACTfound.STREAMING_MODE_SMALLfound.STREAMING_MODE_MEDIUMfound.STREAMING_MODE_LARGEfound.STREAMING_MODE_SERIALfound.next_prefix(key)Returns the immediatly next byte sequence that is not prefix ofkey.found.lt(key, offset=0)found.lte(key, offset=0)found.gt(key, offset=0)found.gte(key, offset=0)asyncfound.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 bstorebstore.BStoreExceptionException specific tobstore.bstore.make(name, prefix)Handle over abstorecallednamewithprefix.asyncbstore.get_or_create(tx, bstore, blob)bstore.get(tx, bstore, uid)from found import nstorenstore.NStoreExceptionException specific tonstore.nstore.make(name, prefix, n)Create a handle over anstorecallednamewithprefixandncolumns.The argumentnameshould be a string, it is really meant to ease
debugging.prefixshould be a tuple that can be packed withfound.pack. Last but not least,nis 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 withtx, as part ofnstore, additemsassociated withvalue.nstore.remove(tx, nstore, *items)In the database associated withtx, as part ofnstore, removeitemsand the associated value.asyncnstore.get(tx, nstore, *items)In the database associated withtx, as part ofnstore, get the
value associated withitems. If there is no such items innstore,
returnsNone.nstore.var(name)Create a variable callednamefor use withnstore.query.asyncnstore.query(tx, nstore, pattern, *patterns)In the database associated withtx, as part ofnstore, generate
mappings that matchpatternandpatterns. Bothpatternandpatternsmay containnstore.varthat will be replaced with
matching values in the generic tuple store.from found import eavstoreeavstore.make(name, prefix)Create a handle over an eavstore callednamewithprefix.The argumentnameshould be a string, it is really meant to ease
debugging.prefixshould be a tuple that can be packed withfound.pack.eavstore.create(tx, eavstore, dict)Store a dictionary.In the database associated withtx, as part ofeavstore, savedictand returns its unique identifier.asynceavstore.get(tx, eavstore, uid)Fetch a dictionary.In the database associated withtx, as part ofeavstore, retrieve
the dictionary associated withuid. If there is no such dictionary,
returns an empty dictionary.eavstore.remove(tx, eavstore, uid)Clear a dictionary.In the database associated withtx, as part ofeavstore, remove
the dictionary associated withuid.eavstore.update(tx, eavstore, uid, dict)Update a dictionary.In the database associated withtx, as part ofeavstore, replace
the dictionary associated withuidwithdict.asynceavstore.query(tx, eavstore, key, value)Lookup dictionaries according to sppecification.In the database associated withtx, as part ofeavstore, generates
unique identifier for dictionaries that havekeyequal tovalue.from found import pstorepstore.PStoreExceptionException specific topstore.pstore.make(name, prefix, pool)A handle over apstorecallednamewithprefix, that will usepool.asyncpstore.index(tx, store, docuid, counter)Associatesdocuidwithcounter.Coroutine that associates the identifierdocuidwith the dict-likecounterinside the database associated withtxatstorefor
later retriaval withpstore.search.countermust be a dict-like mapping string to integers bigger than
zero.asyncpstore.search(tx, store, keywords, limit)Return a sorted list of at mostlimitdocuments matchingkeywords.