Skip to main content

A bulk updater for Microsoft CosmosDB

Project description

CosmosDB bulk updater

A package to update a tons of documents in Microsoft CosmosDB

How it works?

It executes a query and iterate all the items executing an update function defined by the user. This query will be executed until it return any result

Usage

The sample bellow show how to add a new field into the all database documents

from cosmosdb_bulk_updater import BulkUpdater, Database


def update_document(document: dict):

    document['new_field'] = 'blah'
    return document


def run():
    database = Database(
        endpoint="[ENDPOINT]",
        key="[YOUR_KEY]",
        database="[DATABASE]",
        collection="[COLLECTION]"
    )

    updater = BulkUpdater(
        database=database,
        query="SELECT TOP 500 VALUE c FROM c where NOT IS_DEFINED(c.new_field)"
    )

    updater.execute_update(
        execute_fn=update_document
    )


if __name__ == '__main__':
    run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cosmosdb-bulk-updater, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size cosmosdb_bulk_updater-0.5.0-py3-none-any.whl (4.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cosmosdb-bulk-updater-0.5.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page