Skip to main content

A simple interface to manage collections in Redis.

Project description

RedisCollectionDB

Description

RedisCollectionDB is a Python library that provides an easy-to-use interface for managing collections and their items within a Redis database. It allows for the addition and removal of collections and items, listing of current collections and items, and subscribes to changes in collections and items via Redis' publish/subscribe mechanism.

Installation

Install RedisCollectionDB using pip:

pip install rediscollectiondb

How to Use

First, ensure you have Redis running on your local machine or a server.

from rediscollectiondb import RedisDB

# Initialize the RedisDB instance
db = RedisDB(db_name='your_database_name')

# Add a collection
db.add_collection('books')

# Add items to the collection
db.add_item('books', 'The Great Gatsby')
db.add_item('books', '1984')

# List collections
print(db.list_collections())

# List items in a collection
print(db.list_items('books'))

# Remove an item
db.remove_item('books', '1984')

# Remove a collection
db.remove_collection('books')

Example

This example demonstrates adding a collection, adding items to it, and then listing and removing items and the collection.

if __name__ == '__main__':
    db = RedisDB(db_name='myapp')

    db.add_collection('books')
    db.add_item('books', 'The Great Gatsby')
    db.add_item('books', '1984')

    print("Collections:", db.list_collections())
    print("Books items:", db.list_items('books'))

    db.remove_item('books', '1984')
    print("Books items after removal:", db.list_items('books'))

    db.remove_collection('books')
    print("Collections after removing books:", db.list_collections())

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

rediscollectiondb-0.1.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rediscollectiondb-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file rediscollectiondb-0.1.1.tar.gz.

File metadata

  • Download URL: rediscollectiondb-0.1.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for rediscollectiondb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 10a47eb3ffefa70f0caa8faaeeaf7763241162704c5bfa7b4cad337a0172a2d9
MD5 03dc193493ee1020d471ca2bd31a462e
BLAKE2b-256 d2731e43c7345530605a0f5b31da8270f5e8da06acdeed2fcac0da7d766d21bf

See more details on using hashes here.

File details

Details for the file rediscollectiondb-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rediscollectiondb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5035cc16ff95e761dc77adcdcb7b4130c1d08bf458a83141e595346c19269bef
MD5 42ce1dd1b0d01506cee5de9efdae7305
BLAKE2b-256 cf8adff09bd30d9bd1c116f38560d2c0303400c712cd8fc700b9daba1b6a3d0a

See more details on using hashes here.

Supported by

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