Notes up to the point where you bring the data on documentDB
on Microsoft Azure to your hand (local PC) and store the documents in the array list
Windows 10
Python 2.7
pydocumentdb
--DocumentDB settings on Azure
abc_server.documents.azure.com
abc_database
abc_collection
abc_api
--Please rewrite each ʻabc ... `when setting on Azure as appropriateCollection? --For example, here is the concept: - https://docs.microsoft.com/ja-jp/azure/documentdb/documentdb-introduction
pip install pydocumentdb
# -*- coding: utf-8 -*-
## library setting
import pydocumentdb.document_client as document_client
##various settings
HOST = 'abc_server.documents.azure.com:443/'
DATABASE_ID = 'abc_database'
COLLECTION_ID = 'abc_collection'
MASTER_KEY = 'abc_api'
#documentDb client instance created
client = document_client.DocumentClient(HOST, {'masterKey': MASTER_KEY})
# database/collection definition
database_definition = {'id': DATABASE_ID }
collection_definition = { 'id': COLLECTION_ID }
##Define DB connection
databases = list(client.QueryDatabases({
'query': 'SELECT * FROM root r WHERE r.id=@id',
'parameters': [
{ 'name':'@id', 'value': database_definition['id'] }
]
}))
db = databases[0]
##Define Collection
collections = list(client.QueryCollections(
db['_self'],
{
'query': 'SELECT * FROM root',
'parameters': [
{ 'name':'@id', 'value': collection_definition['id'] }
]
}))
collection = collections[0]
##Store Documents
###Box for Documents
list = []
###Let's put them one by one
for doc in client.ReadDocuments(collection['_self']):
list.append(doc)
--Each document comes in json
format, so a separate parse is required-
――This time, I felt like bringing the whole amount, but if you want to partially remove it, you need to change query
, but that is separate.
――Please use it for the purpose of extracting for the time being.
Recommended Posts