该pydocumentdb.document_client.DocumentClient
对象有一个CreateCollection()
方法,在此处定义。
使用这种方法创建集合时,需要指定数据库链接(已经知道),集合(如果没有创建,我不知道如何引用它)和选项。
创建集合时我想控制的参数是:
其中一些参数的枚举似乎在此处定义,但我在http_constants.py 中看不到任何潜在有用的 HTTP 标头,而且我看不到 RU 在哪里发挥作用或有凝聚力的“集合”对象在哪里作为参数传递。
您可以参考source sample code
from here和rest api
from here。
import pydocumentdb;
import pydocumentdb.errors as errors
import pydocumentdb.document_client as document_client
config = {
'ENDPOINT': 'https://***.documents.azure.com:443/',
'MASTERKEY': '***'
};
# Initialize the Python DocumentDB client
client = document_client.DocumentClient(config['ENDPOINT'], {'masterKey': config['MASTERKEY']})
databaseLink = "dbs/db"
coll = {
"id": "testCreate",
"indexingPolicy": {
"indexingMode": "lazy",
"automatic": False
},
"partitionKey": {
"paths": [
"/AccountNumber"
],
"kind": "Hash"
}
}
collection_options = { 'offerThroughput': 400 }
client.CreateCollection(databaseLink , coll, collection_options)
希望对你有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句