Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsileo/blobstash-python
Python client for BlobStash. Mirror of https://git.sr.ht/~tsileo/blobstash-python
https://github.com/tsileo/blobstash-python
blobstash blobstash-python
Last synced: 3 months ago
JSON representation
Python client for BlobStash. Mirror of https://git.sr.ht/~tsileo/blobstash-python
- Host: GitHub
- URL: https://github.com/tsileo/blobstash-python
- Owner: tsileo
- License: mit
- Created: 2017-08-06T17:44:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-23T16:48:18.000Z (almost 5 years ago)
- Last Synced: 2024-10-07T13:06:37.862Z (3 months ago)
- Topics: blobstash, blobstash-python
- Language: Python
- Homepage:
- Size: 59.6 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BlobStash Python Client
[![builds.sr.ht status](https://builds.sr.ht/~tsileo/blobstash-python.svg)](https://builds.sr.ht/~tsileo/blobstash-python?)
[![PyPI](https://img.shields.io/pypi/v/blobstash-docstore.svg)](https://pypi.python.org/pypi/blobstash)
[![PyPI](https://img.shields.io/pypi/pyversions/blobstash-docstore.svg)](https://pypi.python.org/pypi/blobstash)
[![License](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://git.sr.ht/~tsileo/blobstash-python/tree/master/LICENSE)
Client for [BlobStash](https://git.sr.ht/~tsileo/blobstash).
## Examples
### Document Store
```python
>>> from blobstash.docstore import DocStoreClient, Q
>>> client = DocStoreClient(api_key='123')
>>> col = client.my_collection
>>> col>>> # Insert data
>>> k = col.insert({'key': 10, 'k1': True, 'k2': None, 'l': [1, 2, 'c']})
>>> k>>> # Get a single document
>>> col.get_by_id(k)
{'_id': ,
'k1': True,
'k2': None,
'key': 10,
'l': [1, 2, 'c']}
>>> col.get_by_id('14d854f6e9ee37a9cd8c1ffc')
{'_id': ,
'k1': True,
'k2': None,
'key': 10,
'l': [1, 2, 'c']}
# Native Python query using Q
>>> for doc in col.query(Q['key'] == 10):
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
>>> for doc in col.query(Q['key'] > 10):
... print(doc)>>> for doc in col.query():
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
>>> for doc in col.query(Q['l'].contains(1)):
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
>>> for doc in col.query(Q['l'][0] == 1):
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
>>> # Raw Lua query
>>> # 1. in shortcut mode
>>> for doc in col.query("doc.k1 == true and doc.key ~= nil"):
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
>>> # 2. full Lua script
>>> from blobstash.docstore.query import LuaScript
>>> script = LuaScript("""
... return function(doc)
... if doc.key == 10 then
... return true
... end
... return false
... end
... """)
>>> for doc in col.query(script):
... print(doc)
{'k1': True, 'k2': None, 'key': 10, 'l': [1, 2, 'c'], '_id': }
```## LICENSE
MIT