Skip to main content

A simple Python context manager for easy Google Forestore batched writes.

Project description

firestore-batch

A Python context manager for easy Google Forestore batched writes.

What it does for you

  • Creates a new batch on entering.
  • Takes care of the 500-operation limit. When the limit is hit, it commits accumulated operations to the database and creates a new batch.
  • Commits all operations on exit.

Usage

Install with pip:

pip install firestore-batch

Use in your code:

# Initialize the app
from firebase_admin import initialize_app, firestore
initialize_app()
db = firestore.client()

# Make lots of batched writes
from firestore_batch import Batch

with Batch(db) as batch:
    for i in range(1000):
        batch.set(doc_ref, {f'property_{i}': f'value_{i}'})

Methods

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

firestore_batch-0.0.1.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

firestore_batch-0.0.1-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

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