I follow the instruction at https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-use-stored-procedures-triggers-udfs#stored-procedures---python-sdk
When I implemented this:
container.execute_stored_procedure(sproc_link)
the error shows up:
Instance of 'ContainerProxy' has no 'execute_stored_procedure' member
Dig deep into the API at https://docs.microsoft.com/en-us/python/api/overview/azure/cosmosdb?view=azure-python
And yes, there is no execute_stored_procedure
But still found it here: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-cosmos/4.1.0/_modules/azure/cosmos/scripts.html
Did anyone meet this?
@namnh06 It looks like that doc is out of date. There is a sub-object on container that contains what you are looking for:
container.scripts.execute_stored_procedure()
Here is a test showing the usage https://github.com/Azure/azure-sdk-for-python/blob/22bd8ce1b08cd20ade20f48de21fa605abbaf232/sdk/cosmos/azure-cosmos/test/test_crud.py#L614-L645
@Rodrigossz can you look at getting the doc fixed?
@namnh06 BTW, in the future please file issues in the new repo: https://github.com/Azure/azure-sdk-for-python/. I have gone ahead and transferred this issue there.
Hi @southpolesteve , thanks for your hard work, it's working now.
For whom who looking for this:
url = os.environ["COSMOS_END_POINT"]
key = os.environ["COSMOS_KEY"]
client = CosmosClient(url, key)
database_name = 'ClickVuVerifyDB'
database = client.get_database_client(database_name)
container_name: str = 'UserContainer'
container = database.get_container_client(container_name)
stored_procedure_name = 'spCountRecords'
container.scripts.execute_stored_procedure(stored_procedure_name, partition_key=2)
PR Created. Let's wait.
PR Merged. Will be published in the next days. Tks
Fixed.