Skip to main content

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 spaces table containing spaceName and isFull fields

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

lockedin_handeler-1.5.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

lockedin_handeler-1.5.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file lockedin_handeler-1.5.0.tar.gz.

File metadata

  • Download URL: lockedin_handeler-1.5.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lockedin_handeler-1.5.0.tar.gz
Algorithm Hash digest
SHA256 96935ce726db7f13c9c9abb936151cc2aa46927947bdf89f156240b666deda7c
MD5 05b0faf769c05744648c988c6ed973fe
BLAKE2b-256 04f77824ab7d84bfb07ad6c96025570ee80079ac1000fc6012ea657647060a64

See more details on using hashes here.

File details

Details for the file lockedin_handeler-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lockedin_handeler-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69781b525200751134b09ca4649d87527b62e886a5655e0aea2b301ea22d7021
MD5 8df3da287569b6d86ea0a9a633951f76
BLAKE2b-256 40067f22b5329bb1796707c8b0fbbccb846b26900366f55bde5916f0ac3481bd

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