Skip to content

Repository files navigation

cosmodol

Azure Cosmos DB Data Object Layer — access Cosmos DB through a dict-like dol Mapping / MutableMapping interface.

To install: pip install cosmodol

Scope

cosmodol targets the NoSQL (Core / SQL) API of Azure Cosmos DB via the official azure-cosmos Python SDK.

If your Cosmos DB account was provisioned with the MongoDB API, use pymongo directly with mongodol — Cosmos's MongoDB-API accounts speak the MongoDB wire protocol, and cosmodol cannot reach them.

For Azure Blob Storage, see the sibling package azuredol.

Quick start

from cosmodol import cosmos_store

# Single-partition store (simplest)
store = cosmos_store(
    connection_string="AccountEndpoint=https://localhost:8081/;AccountKey=…",
    database="mydb",
    container="mycontainer",
    partition_key_value="my-partition",
)

store["k1"] = {"name": "Alice", "age": 30}
store["k1"]  # → {"id": "k1", "_pk": "my-partition", "name": "Alice", "age": 30}
"k1" in store  # → True
del store["k1"]

See also

About

Azure Cosmos DB Data Object Layer — dol-style Mapping interfaces over the NoSQL/Core API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages