Try to extract Azure document DB document with pydocumentdb

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

Trial premise

Collection? --For example, here is the concept: - https://docs.microsoft.com/ja-jp/azure/documentdb/documentdb-introduction

Anyway install & initial setup

pip install pydocumentdb

Let's write in Python.

# -*- 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)

Stored result

--Each document comes in json format, so a separate parse is required-

Remarks

――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

Try to extract Azure document DB document with pydocumentdb
Try to extract Azure SQL Server data table with pyodbc
Try to operate DB with Python and visualize with d3
Try to factorial with recursion
Try to extract the features of the sensor data with CNN
Try to operate Facebook with Python
Try to profile with ONNX Runtime
Try to output audio with M5STACK
Try to extract a character string from an image with Python3
Try to reproduce color film with Python
Try logging in to qiita with Python
Access Azure Cosmos DB with Spring Boot
Try to predict cherry blossoms with xgboost
Try converting to tidy data with pandas
Quickly try to visualize datasets with pandas
First YDK to try with Cisco IOS-XE
Try to generate an image with aliasing
Try to poke DB on IBM i with python + JDBC using JayDeBeApi
Extract the Azure SQL Server data table with pyodbc and try to make it numpy array / pandas dataframe
Try to make your own AWS-SDK with bash
Try to solve the fizzbuzz problem with Keras
Try to aggregate doujin music data with pandas
Try to solve the man-machine chart with Python
Try to draw a life curve with python
Try to communicate with EV3 and PC! (MQTT)
How to try the friends-of-friends algorithm with pyfof
Try to make a "cryptanalysis" cipher with Python
Try to automatically generate Python documents with Sphinx
Try to make a dihedral group with Python
Try to make client FTP fastest with Pythonista
Try to detect fish with python + OpenCV2.4 (unfinished)
Hit Nature Remo's API to record room temperature with Azure Functions and Cosmos DB
Try to solve the programming challenge book with python3
[First API] Try to get Qiita articles with Python
I tried to extract features with SIFT of OpenCV
Try to make a command standby tool with python
Try to dynamically create a Checkbutton with Python's Tkinter
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
Try to predict forex (FX) with non-deep machine learning
Try to make RESTful API with MVC using Flask 1.0.2
Schema-driven development with Responder: Try to display Swagger UI
[GCP] Try a sample to authenticate users with Firebase
How to extract null values and non-null values with pandas
How to extract non-missing value nan data with pandas
Try to get the contents of Word with Golang
[Neo4J] ④ Try to handle the graph structure with Cypher
A sample to try Factorization Machines quickly with fastFM
Try to tamper with requests from iphone with Burp Suite
Try to automate pdf format report creation with Python
Try to extract high frequency words using NLTK (python)
Try to specify the axis with PyTorch's Softmax function
How to extract non-missing value nan data with pandas