Skip to main content

No project description provided

Project description

Data Snack

About

Data Snack is a minimalistic framework for storing and accessing structured data.

It uses an Entity objects to define a schema for your data. Snack provides an interface for automatically serializing and storing entities in a cache database of you choice. General interface that allows you to use different backends: redis, memcached.

Install

Data Snack can be easily installed using pypi repository.

pip install data_snack

Usage

This examples shows a basic usage of defining an entity and using Snack to save and load it from the cache. More examples can be found in the Examples section.

Example 1 - Creating new entities and saving

1. Define entities

from dataclasses import dataclass
from typing import Text
from data_snack.entities import Entity

@dataclass
class Person(Entity):
    index: Text
    name: Text

2. Connect to redis

import redis
redis_connection = redis.Redis(host='127.0.0.1', port=6379, password='')

3. Create snack instance

from data_snack import Snack
snack = Snack(connection=redis_connection)  # create instance
snack.register_entity(Person, keys=['index'])  # register your entity

4. Save and load your entities using Snack

snack.set(Person("1", "John"))
# 'Person-1'
snack.get(Person, ["1"])
# Person(index='1', name='John')
snack.mset([Person("1", "John"), Person("2", "Anna")])
# ['Person-1', 'Person-2']
entities = snack.mget(CarEntity, [["1"], ["2"]])
# [Person(index='1', name='John'), Person(index='2', name='Anna')]

Contact

Plugin was created by the Data Science team from Webinterpret.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_snack-0.0.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

data_snack-0.0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file data_snack-0.0.2.tar.gz.

File metadata

  • Download URL: data_snack-0.0.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for data_snack-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d67a482287bbb6ab109990803487bc72afae953e08c77bd796a102c19c64022f
MD5 d62c2892fb562de20d96ea98f6500e2d
BLAKE2b-256 14d8cfa39b5b1ed5a551144daacc2d6dc0eadf5739760cb08ccf8ce15811f650

See more details on using hashes here.

File details

Details for the file data_snack-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: data_snack-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for data_snack-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f4f9cef4cd208ebd3b8298dbefcf4b300cf4935335510c0a97c48ae1490786e
MD5 03adf6351ccf3691b46cd4f7a3f166dc
BLAKE2b-256 e317c317291ec6e4c0f71a759d8404918b2d936925837fe6bd1559bfb2f5e4b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page