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
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
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
File details
Details for the file rediscollectiondb-0.1.0.tar.gz.
File metadata
- Download URL: rediscollectiondb-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d2c18b40e08d37838824487cc4d7f8fe721d246f027c3611c92f2616afe5ef3
|
|
| MD5 |
3ca24467fee724b81d9a8947a068c8ff
|
|
| BLAKE2b-256 |
a4c30c2f29339e1bff485c25af7366717098f9ef9615bc56a908f73919514730
|
File details
Details for the file rediscollectiondb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rediscollectiondb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33ba25f6c2fb16e59a7dd6c87f057edd47d4acabc978da160ce6e0d8c1e8a4fa
|
|
| MD5 |
efbc0053cfd816f8e73a41b28b7811b4
|
|
| BLAKE2b-256 |
06bc27f90957f192326cb340595c9b381d4b483c4daa9ca5c2e24ad4750ffac5
|