Skip to main content

No project description provided

Project description

Data Snack

About

Install

Plugin can be easily installed using pypi repository.

pip install data_snack

Usage

Example 1

1. Define entities

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

@dataclass
class CarEntity(Entity):
    index: Text
    price: int
   brand: 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(CarEntity, keys=['index'])  # register your entity

4. Create test dataset

import pandas as pd
df = pd.DataFrame([
    {"index": "1", "brand": "Audi", "price": 17000},
    {"index": "2", "brand": "Opel", "price": 4000},
    {"index": "3", "brand": "Audi", "price": 7000},
    {"index": "4", "brand": "Toyota", "price": 14000},
])
data = [CarEntity(**v) for v in df.to_dict(orient="records")]

5. Save and load data

snack.set(data[1])
# 'CarEntity-2'
snack.get(CarEntity, ["1"])
# CarEntity(index='1', price=17000, brand='Audi')
entities = snack.mget(CarEntity, [["1"], ["2"], ["3"]])
# [CarEntity(index='1', price=17000, brand='Audi'), CarEntity(index='2', price=4000, brand='Opel'), CarEntity(index='3', price=7000, brand='Audi')]
snack.mset(data)
# ['CarEntity-1', 'CarEntity-2', 'CarEntity-3', 'CarEntity-4']

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.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

data_snack-0.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: data_snack-0.0.1.tar.gz
  • Upload date:
  • Size: 5.3 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.1.tar.gz
Algorithm Hash digest
SHA256 6ce4098c58119ee02b00b00bd13a30e8003d280b5d82cebf38b31c6a9dbe185e
MD5 025a32a15f1b63b098d6404339f8938e
BLAKE2b-256 259300f9142f0200ace8857ffe83b54c2e56f245a17a493bcbb91325b35bbbe3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: data_snack-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b05b6668fdea15c3504f685fc1ebaa3aa18e76f4901f8a7e12817adbb2280add
MD5 1216e0d5eb4475d91d8f1d234e694f00
BLAKE2b-256 67461371378c0e93f4fd65a51120d5b3ff19750697f3dca90c63b3bf506114e9

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