A simple Python package for managing space availability in Convex
Project description
Convex Space Manager
A simple Python package for managing space availability in Convex databases.
Features
- 🚀 Simple API - Easy-to-use interface for space management
- 🔄 Batch Updates - Update multiple spaces at once
- ⚡ Real-time - Instant updates to your Convex database
- 📦 Lightweight - Minimal dependencies, just Python + Convex
- 🛠️ Flexible - Works with any space naming convention
Installation
pip install convex-space-manager
Quick Start
from convex_space_manager import convex_sync
# Your space data
spaces = ["space1", "space2", "space3", "space4", "space5"]
availability = [True, False, True, False, True] # True = full, False = available
# Update all spaces at once
convex_sync(availability, spaces, "https://your-deployment.convex.cloud")
Advanced Usage
from convex_space_manager import ConvexSpaceManager
# Initialize manager
manager = ConvexSpaceManager("https://your-deployment.convex.cloud")
# Update individual spaces
manager.update_space("space1", True) # space1 is now full
manager.update_space("space2", False) # space2 is now available
# Update multiple spaces
spaces = ["space1", "space2", "space3"]
availability = [True, False, True]
manager.update_multiple_spaces(spaces, availability)
Requirements
- Python 3.7+
- Convex deployment URL
- Convex database with
spacestable containingspaceNameandisFullfields
Convex Schema
Your Convex database should have a spaces table with this structure:
spaces: defineTable({
spaceName: v.string(),
isFull: v.boolean(),
}).index("by_spaceName", ["spaceName"])
And a mutation function:
export const update_fullness = mutation({
args: {
spaceName: v.string(),
isFull: v.boolean(),
},
handler: async (ctx, args) => {
const existingSpace = await ctx.db
.query("spaces")
.withIndex("by_spaceName", (q) => q.eq("spaceName", args.spaceName))
.first();
if (existingSpace) {
await ctx.db.patch(existingSpace._id, {
isFull: args.isFull,
});
} else {
await ctx.db.insert("spaces", {
spaceName: args.spaceName,
isFull: args.isFull,
});
}
},
});
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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
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 lockedin_handeler-1.7.0.tar.gz.
File metadata
- Download URL: lockedin_handeler-1.7.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae05e79b48e910214c9ec381781f9562413c4ec2337cedbdee58dd45e0250c18
|
|
| MD5 |
021ff684c5794177cea04110f94f6605
|
|
| BLAKE2b-256 |
1bdce7fecf9dd809507eadd859d9d0c8db01bf98741b90b8b4eae04cf7846d7a
|
File details
Details for the file lockedin_handeler-1.7.0-py3-none-any.whl.
File metadata
- Download URL: lockedin_handeler-1.7.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25c443e5abdf17c5996ad8de630e2ff74b6b902ca7148ddd21106bdff0d3755
|
|
| MD5 |
37a2b4a3ef884e658a99c9b1cc9a4ac3
|
|
| BLAKE2b-256 |
7649c0bf14d3c237a440f3d59c2979f2e414ab812ab53ec51a657b8b06c02f70
|