Last active
February 9, 2020 20:22
-
-
Save rchardptrsn/03c8e3c9ce271495dc2c7337f1775e68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create a collection of items in a Container | |
| # Items are the individual rows/records of your dataset | |
| # https://docs.microsoft.com/en-us/python/api/azure-cosmos/azure.cosmos.cosmos_client.cosmosclient?view=azure-python#createcontainer-database-link--collection--options-none- | |
| database_link = 'dbs/' + 'HDIdatabase' | |
| container_definition = {'id': 'HDIcontainer', | |
| 'partitionKey': | |
| { | |
| 'paths': ['/country'], | |
| 'kind': documents.PartitionKind.Hash | |
| } | |
| } | |
| try: | |
| container = client.CreateContainer(database_link=database_link, | |
| collection=container_definition, | |
| options={'offerThroughput': 400}) | |
| except errors.HTTPFailure as e: | |
| if e.status_code == http_constants.StatusCodes.CONFLICT: | |
| container = client.ReadContainer("dbs/" + database['id'] + "/colls/" + container_definition['id']) | |
| else: | |
| raise e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment