ArangoDB with a simple (dict-like or list-like) interface
Project description
arangodol
ArangoDB with a simple (dict-like or list-like) interface
To install: pip install arangodol
A basic ArangoDB persister.
>>> from arangodol import ArangoDbPersister
>>> s = ArangoDbPersister()
>>> k = {'key': '777'} # Each collection will happily accept user-defined _key values.
>>> v = {'val': 'bar'}
>>> for _key in s:
... del s[_key]
...
>>> k in s
False
>>> len(s)
0
>>> s[k] = v
>>> len(s)
1
>>> s[k]
{'val': 'bar'}
>>> s.get(k)
{'val': 'bar'}
>>> s.get({'not': 'a key'}, {'default': 'val'}) # testing s.get with default
{'default': 'val'}
>>> list(s.values())
[{'val': 'bar'}]
>>> k in s # testing __contains__ again
True
>>> del s[k]
>>> len(s)
0
>>> s = ArangoDbPersister(db_name='py2store', key_fields=('name',))
>>> for _key in s:
... del s[_key]
...
>>> s[{'name': 'guido'}] = {'yob': 1956, 'proj': 'python', 'bdfl': False}
>>> s[{'name': 'guido'}]
{'yob': 1956, 'proj': 'python', 'bdfl': False}
>>> s[{'name': 'vitalik'}] = {'yob': 1994, 'proj': 'ethereum', 'bdfl': True}
>>> s[{'name': 'vitalik'}]
{'yob': 1994, 'proj': 'ethereum', 'bdfl': True}
>>> for key, val in s.items():
... print(f"{key}: {val}")
{'name': 'guido'}: {'yob': 1956, 'proj': 'python', 'bdfl': False}
{'name': 'vitalik'}: {'yob': 1994, 'proj': 'ethereum', 'bdfl': True}
ArangoDbStore using tuple keys.
>>> from arangodol import ArangoDbTupleKeyStore
>>> s = ArangoDbTupleKeyStore(collection_name='test', key_fields=('key', 'user'))
>>> k = (1234, 'user')
>>> v = {'name': 'bob', 'age': 42}
>>> if k in s: # deleting all docs in tmp
... del s[k]
>>> assert (k in s) == False # see that key is not in store (and testing __contains__)
>>> orig_length = len(s)
>>> s[k] = v
>>> assert len(s) == orig_length + 1
>>> assert k in list(s)
>>> assert s[k] == v
>>> assert s.get(k) == v
>>> assert v in list(s.values())
>>> assert (k in s) == True # testing __contains__ again
>>> del s[k]
>>> assert len(s) == orig_length
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
arangodol-0.0.2.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file arangodol-0.0.2.tar.gz
.
File metadata
- Download URL: arangodol-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01897ec97c2ed529c5fdadb81f8bf78456792257c86793d0b7481a0e70a841a7 |
|
MD5 | c644325703f82880f57453405229484a |
|
BLAKE2b-256 | 55cc986a2fbaa29c57a64070862f0f993e807387fd44b3ac5a00dc5f145cae23 |
File details
Details for the file arangodol-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: arangodol-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5182aebccdc5e2f61d9f72e2e98c3e8ffec3f5b875a53ca81ab7915a6c88e0f9 |
|
MD5 | 1ca24ebb0a377c04ed7c6bb85c81ef89 |
|
BLAKE2b-256 | 281c0a05397f1dae3afad7b141362b62005ca8fa230aed3d308a0d0527afd301 |