Query and process watson iot device data from cloudant nosql db – developerworks recipes

After configuring Cloudant NoSQL DB as Historian Data Storage for IBM Watson IoT Platform, now send some device data on to IBM Watson IoT Platform following the steps described in the recipe – Visualizing Data in Watson IoT Platform. We can use database naming scheme to dynamically derive the Cloudant NoSQL Database names in data processing code. Data recovery on iphone Here given a sample Python code to dynamically derive Cloudant database names for monthly bucket size starting from 2016-01 to 2016-11. Watson IoT Platform Historian Connector for Cloudant automatically creates Map views based on the device data stored in Cloudant NoSQL DB. A data recovery tool We use these views to query the device data from the Cloudant database.


Data recovery expert Each Map view is indexed using a key, so that we can use that key for our queries. Data recovery jobs Following are the different Map views created automatically by the Connector for Cloudant using different keys as indexes: In this section, we have touched upon the Map views that automatically get created by the Cloudant Connector and how to view them in the Cloudant Dashboard. Database concepts 6th edition We’ll see how to query and process the device data in coming sections below. Cloudant NoSQL DB provides ReST interface to query the data stored in the databases. Database kernel We need to frame the URL to be used and the parameters for the HTTP GET Method. Raid 5 data recovery software The URL consists of Cloudant Host, Cloudant Database, Cloudant Design Document and the Cloudant View. Data recovery pro The Cloudant Host, User Name and Password can be obtained from Bluemix Cloudant Service Credentials: The Cloudant View can be any one of the view created by the Cloudant Connector Module as described under previous section. Data recovery tools mac We need to specify based on the key we want to use as part of our query. Example URL to get records using the view by-deviceId looks as shown below: https://b59f1c15-6c1a-44f2-bc79-e9375297739d-bluemix.cloudant.com/iotp_20wyks_default_2016-11/_design/iotp/_view/by-deviceId To query the device data using cURL statement, we need to specify the Cloudant-Username and Cloudant-Password as part of URL for authentication. Z wave database The URL format for Cloudant Query as part of cURL statement: Example cURL statement to get records using the view by-deviceId looks as shown below: curl https://b59f1c15-6c1a-44f2-bc79-e9375297739d-bluemix:@b59f1c15-6c1a-44f2-bc79-e9375297739d-bluemix.cloudant.com/iotp_20wyks_default_2016-11/_design/iotp/_view/by-deviceId The Cloudant defines certain set of key words to be used as parameters to queries. Database orm Here provided are some of them which we’ll use in our queries in cURL and python statements: For complete details about Cloudant and how to use Cloudant Views with parameters, refer to Bluemix Cloudant API Documentation on Using Views. Refer to GitHub link for cURL Statements to execute the cURL commands for each of the above described queries. Database workbench In the provided sample query statements, replace cloudant-username, cloudant-password, cloudant-host, cloudant-database with actual values before executing the cURL statements. Database best practices Also provide the appropriate correct values for device id and device type for the required queries. In this section, we described about how to frame the URL to use in Cloudant Query. Database schema Also described about querying the device data stored in Cloudant NoSQL DB using cURL statements and provided sample query statements for the reference. To process the device data stored in Cloudant NoSQL DB, we should know the storage data format. Data recovery external hard drive As described in previous sections, there are different Map views getting automatically created by Cloudant Connector Module, we’ll be using those Map views for data processing in this section. For our samples, we have the device data containing a value field with the value in the range between 0 to 1 for illustrating in our queries for this section: “d” : { “value” : 0.521623 } In Cloudant NoSQL DB, the format of one device event data retrieved from a view based on deviceId as key is given below for our reference to understand for querying purpose: In this section, we use Python code samples to execute HTTP GET Method using Requests Python Module and store the response data in the python data structures for further data processing. Database 1 to many Below given are the sample Python Code samples to retrieve and process device data from Cloudant NoSQL database: Query-1: Example of retrieving a list of the first five documents from a database for the device “piCam-1”, applying the view by-deviceId and further process the device data to get data values for the first five documents. Query-2: Example of retrieving third to seventh record for the device “piCam-4” and further process the device data to get data values for the retrieved device data records. Solution: The only change required to solve this query compared to Query-1 is to modify the parameters to contain key, skip and limit keywords: key=”piCam-4″, skip=2 and limit=5 GitHub link for Query-2 in Python Query-3: Example of retrieving most recent device event using view by-date and further process to get the details for device type, event type and device for the most recent device event. Solution: The changes required to solve this query is change in view and the parameters to GET request. Data recovery galaxy s6 We need to use the view by-date and sort the device events in descending order and pick up the first record. Os x data recovery software GitHub link for Query-3 in Python Query-4: Example of retrieving the device events for 2 devices – piCam-2 and piCam-4 using view by-deviceId and further processing the device data to get count of events for each of the device: Solution: We need to use the view by-deviceId and the parameter keys to specify 2 devices for which we need to get device data, and then count the records after storing into Python List. Database technology GitHub link for Query-4 in Python Query-5: Example of retrieving the device events between 2 milliseconds values using the view by-milliseconds and further process the device data to get events details. Solution: We need to use the view by-milliseconds and the keys – startkey and endkey as parameters to HTTP GET request. Database queries definition GitHub link for Query-5 in Python In this section, we described how we can retrieve device data and further process the data using Python with the help of Python requests Module. As we have seen in previous sections, while querying device data from Cloudant NoSQL DBs that the important part of the query statement is framing the URL. Data recovery mac free The URL is database name specific. Data recovery phone Hence, to retrieve device data from multiple Cloudant NoSQL databases, we need to frame multiple number of URLs for each query statement and execute them separately as separate queries. In this section, let us see sample query to retrieve device data from 2 different Cloudant NoSQL databases and further process the device data using Python Code. Database normalization We can dynamically derive the Cloudant NoSQL Databases name using database naming scheme described under the section – Device Data Details stored in Cloudant NoSQL Database. Query to retrieve Device Data from 2 Cloudant Databases: Let us assume the purpose of our query is to retrieve device events from 2 databases using the view by-deviceId and further process the device records to find out the count of events from each device. We need to frame 2 URLs for retrieving device data from 2 Cloudant Databases. Data recovery quote Ether we can statically specify the database names or write code to dynamically derive the database name using database naming scheme. Database key types In our sample, we are specifying the 2 database names statically in the code. Database instance We invoke HTTP GET request separately fo
r each of the URL and then further process the device data to get count of events from each device. Data recovery raid 0 GitHub link for the query After configuring Cloudant NoSQL DB as Historian Data Storage for Watson IoT Platform and successfully storing the device data in Cloudant NoSQL database, in this recipe, we described about: To know about How to Configure and use Cloudant NoSQL DB as Historian Data Storage for Watson IoT, refer to first recipe of this series – Configure Cloudant NoSQL DB as Historian Data Storage for IBM Watson IoT To know about how to Link between Cloudant NoSQL DB and Line Chart Card, visualize the device data on Watson IoT Platform, refer to next recipe of this series: Visualize Watson IoT Device Data stored in Cloudant NoSQL DB.

banner