Feature collection storage for DossierStack
Project description
`dossier.store` is a Python package that provides database storage for
feature collections in DossierStack. It is built on top of `kvlayer`, so
it supports many database backends like PostgreSQL, Accumulo and Redis.
`dossier.store` also provides support for defining basic indexes.
### Installation
`dossier.store` is on PyPI and can be installed with `pip`:
```bash
pip install dossier.store
```
Currently, `dossier.store` requires Python 2.7. It is not yet Python 3
compatible.
### Documentation
API documentation with examples is available as part of the Dossier Stack
documentation:
[http://dossier-stack.readthedocs.org](http://dossier-stack.readthedocs.org#module-dossier.store)
### Basic example
A full working example that uses local memory to store a feature collection:
```python
from dossier.fc import FeatureCollection
from dossier.store import Store
import kvlayer
import yakonfig
yaml = """
kvlayer:
app_name: store
namespace: dossier
storage_type: local
"""
with yakonfig.defaulted_config([kvlayer], yaml=yaml):
store = Store(kvlayer.client())
fc = FeatureCollection({u'NAME': {'Foo': 1, 'Bar': 2}})
store.put([('1', fc)])
print store.get('1')
```
### Example using indexes
Here is another example that demonstrates use of indexing to enable a
poor man's case insensitive search:
```python
fc = dossier.fc.FeatureCollection()
fc[u'NAME'][u'foo'] += 1
fc[u'NAME'][u'bar'] = 42
kvl = kvlayer.client()
store = dossier.store.Store(kvl)
# Index transforms must be defined on every instance of `Store`.
# (The index data is persisted; the transforms themselves are
# ephemeral.)
store.define_index(u'name_casei',
create=feature_index(u'NAME'),
transform=lambda s: s.lower().encode('utf-8'))
store.put('{yourid}', fc) # `put` automatically updates indexes.
assert list(store.index_scan(u'name_casei', 'FoO'))[0] == '{yourid}'
```
feature collections in DossierStack. It is built on top of `kvlayer`, so
it supports many database backends like PostgreSQL, Accumulo and Redis.
`dossier.store` also provides support for defining basic indexes.
### Installation
`dossier.store` is on PyPI and can be installed with `pip`:
```bash
pip install dossier.store
```
Currently, `dossier.store` requires Python 2.7. It is not yet Python 3
compatible.
### Documentation
API documentation with examples is available as part of the Dossier Stack
documentation:
[http://dossier-stack.readthedocs.org](http://dossier-stack.readthedocs.org#module-dossier.store)
### Basic example
A full working example that uses local memory to store a feature collection:
```python
from dossier.fc import FeatureCollection
from dossier.store import Store
import kvlayer
import yakonfig
yaml = """
kvlayer:
app_name: store
namespace: dossier
storage_type: local
"""
with yakonfig.defaulted_config([kvlayer], yaml=yaml):
store = Store(kvlayer.client())
fc = FeatureCollection({u'NAME': {'Foo': 1, 'Bar': 2}})
store.put([('1', fc)])
print store.get('1')
```
### Example using indexes
Here is another example that demonstrates use of indexing to enable a
poor man's case insensitive search:
```python
fc = dossier.fc.FeatureCollection()
fc[u'NAME'][u'foo'] += 1
fc[u'NAME'][u'bar'] = 42
kvl = kvlayer.client()
store = dossier.store.Store(kvl)
# Index transforms must be defined on every instance of `Store`.
# (The index data is persisted; the transforms themselves are
# ephemeral.)
store.define_index(u'name_casei',
create=feature_index(u'NAME'),
transform=lambda s: s.lower().encode('utf-8'))
store.put('{yourid}', fc) # `put` automatically updates indexes.
assert list(store.index_scan(u'name_casei', 'FoO'))[0] == '{yourid}'
```
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
dossier.store-0.3.4.tar.gz
(12.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
dossier.store-0.3.4-py2.7.egg
(26.5 kB
view details)
File details
Details for the file dossier.store-0.3.4.tar.gz.
File metadata
- Download URL: dossier.store-0.3.4.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
936aff64c9ef0b96651daa1ead13509c6d8127072a6c318f63f0c96b6e08af34
|
|
| MD5 |
33dced21e9520b24806274439a319acf
|
|
| BLAKE2b-256 |
3669eba40b67c775da0937df34b3d2240455a077268daa2cda6b7e4220ea64ff
|
File details
Details for the file dossier.store-0.3.4-py2.7.egg.
File metadata
- Download URL: dossier.store-0.3.4-py2.7.egg
- Upload date:
- Size: 26.5 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034aa2aaaed497f14cf15ad2cc51272e82eef31eb372c7e5291e25f1be300883
|
|
| MD5 |
c3162c63f558607407c4718fb6666b79
|
|
| BLAKE2b-256 |
c53dcf70ba6e3ae805ca2266758d10960c0ae2411607a01246d6c01ba0ca9d23
|