{"id":46820,"date":"2024-12-19T00:00:00","date_gmt":"2024-12-19T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/griddb-cloud-quick-start-guide\/"},"modified":"2025-11-13T12:57:12","modified_gmt":"2025-11-13T20:57:12","slug":"griddb-cloud-quick-start-guide","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/","title":{"rendered":"GridDB Cloud Quick Start Guide"},"content":{"rendered":"<p><style>\n  .toc_title {\n    font-weight: 700;\n    text-align: center;\n}\n<\/style>\n<\/p>\n<p>GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide.<\/p>\n<p>In this quick start guide, you will learn how to insert IoT data into the GridDB Cloud, learn how to test the viability of your connection, and learn the basic CRUD commands (Create, Read, Update, Delete).<\/p>\n<div id=\"toc_container\" style=\"background: #f9f9f9 none repeat scroll 0 0; border: 1px solid #aaa;    display: table;  font-size: 95%; margin-bottom: 1em; padding: 20px; width: auto;\">\n<p class=\"toc_title\">\n    Contents\n  <\/p>\n<ul class=\"toc_list\" style=\"list-style: outside none none !important;\">\n<li>\n      <a href=\"#preparation\">0 Preparation<\/a>\n    <\/li>\n<li>\n      <a href=\"#whitelist\">1 Whitelisting Your IP Address <\/a>\n    <\/li>\n<li>\n      <a href=\"#user\">2 Adding GridDB Users and Granting DB Access<\/a>\n    <\/li>\n<li>\n      <a href=\"#check-connection\">3 Checking your GridDB Connection<\/a>\n    <\/li>\n<li>\n      <a href=\"#first-container\">4 Creating your First Time Series &#038; Collection Containers<\/a>\n    <\/li>\n<li>\n      <a href=\"#crud\">5 CRUD with GridDB Cloud (Create, Read, Update, Delete)<\/a>\n    <\/li>\n<li>\n      <a href=\"#ingest\">6 Ingesting Sample IoT Data<\/a>\n    <\/li>\n<li>\n      <a href=\"#analysis\">7 Running Data Analysis<\/a>\n    <\/li>\n<\/ul>\n<\/div>\n<h2 id=\"preparation\">Preparation<\/h2>\n<p>Before we jump into <em>how<\/em> to use the GridDB Cloud, let&#8217;s go over some basic preparation.<\/p>\n<h3>Sign Up for GridDB Cloud Free Plan<\/h3>\n<p>If you would like to sign up for a GridDB Cloud Free instance, you can do so in the following link: <a href=\"https:\/\/form.ict-toshiba.jp\/download_form_griddb_cloud_freeplan_e?utm_source=griddbnet&amp;utm_medium=quickstartblog\">https:\/\/form.ict-toshiba.jp\/download_form_griddb_cloud_freeplan_e<\/a>.<\/p>\n<p>You can watch a video on how easy it is to sign up here:<\/p>\n<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/NtESMSHDOOk?si=3GwmsE6wVvi1REhz\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h3>Clone GitHub Repository<\/h3>\n<p>To follow along and run these sample code snippets, please clone the repository here:<\/p>\n<p><code>$ git clone https:\/\/github.com\/griddbnet\/Blogs.git --branch cloud-quick-start-worldwide<\/code><\/p>\n<h3>Source Code Overview<\/h3>\n<p>We have prepared some basic HTTP Requests that can help jump-start your journey with GridDB Cloud. These requests are shared via three different programming interfaces: CLI scripts (aka bash, in the <code>bash\/<\/code> dir), node.js, and python.<\/p>\n<p>For example, the first command will be to make sure the connection between your machine and the cloud can be made; to do so, we will run an HTTP Requests to a specific endpoint using just bash (with cURL), and then with node.js\/python scripts.<\/p>\n<h3>Set Up For Running Sample Code<\/h3>\n<p>To ensure your HTTP Requests have the proper connection details, copy the env.example file (from the GitHub Repo shared in the section above) and rename it to <code>.env<\/code>. You must fill in your personal variables (ie. your GridDB Cloud Web API endpoint as well as your user\/pass combo encoded into base64).<\/p>\n<p>To get proper creds, you will need to gather the username\/password combination into base 64separated by a colon; for example: admin:admin becomes <code>YWRtaW46YWRtaW4=<\/code>. You can encode those values by using the following website: <a href=\"https:\/\/www.base64encode.org\/\">https:\/\/www.base64encode.org\/<\/a><\/p>\n<p>The WEBAPI Url can found on the main page of your GridDB Dashboard.<\/p>\n<p>Here is an example of a <code>.env<\/code> file.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">export GRIDDB_WEBAPI_URL=\"https:\/\/cloud51e32re97.griddb.com:443\/griddb\/v2\/gs_clustermfcloud5314927\/dbs\/ZV8YUerterlQ8\"\nexport USER_PASS=\"TTAxZ2FYMFrewwerZrRy1pc3JrerehZWw6avdfcvxXNyYWVs\"<\/code><\/pre>\n<\/div>\n<p>Now run <code>$ source .env<\/code> to load these values into your environment so that you can run these scripts from your CLI.<\/p>\n<h2>First Steps with GridDB Cloud<\/h2>\n<p>Your GridDB Cloud instance can be communicated with via HTTP Requests; every action needed to interact with GridDB will require formulating and issuing an HTTP Request with different URLs, parameters, methods, and payload bodies.<\/p>\n<h3 id=\"whitelist\">1&#46; Whitelisting Your IP Address<\/h3>\n<p>If you haven&#8217;t already, please whitelist your public IP address in the network settings of your GridDB Cloud Management dashboard. You can find your own IP Address by using a simple Google Search: &#8220;What is my IP Address?&#8221;<\/p>\n<p>Or you can go here: <a href=\"https:\/\/whatismyipaddress.com\/\">https:\/\/whatismyipaddress.com\/<\/a><\/p>\n<p>Go to the network tab and add in your IP address. <a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/whitelist-ip.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/whitelist-ip.png\" alt=\"\" width=\"1906\" height=\"1402\" class=\"aligncenter size-full wp-image-31282\" srcset=\"\/wp-content\/uploads\/2024\/12\/whitelist-ip.png 1906w, \/wp-content\/uploads\/2024\/12\/whitelist-ip-300x221.png 300w, \/wp-content\/uploads\/2024\/12\/whitelist-ip-1024x753.png 1024w, \/wp-content\/uploads\/2024\/12\/whitelist-ip-768x565.png 768w, \/wp-content\/uploads\/2024\/12\/whitelist-ip-1536x1130.png 1536w, \/wp-content\/uploads\/2024\/12\/whitelist-ip-600x441.png 600w\" sizes=\"(max-width: 1906px) 100vw, 1906px\" \/><\/a><\/p>\n<p>Note: CIDR Ranges are compatible, so please feel free to add your own if you know it.<\/p>\n<h3 id=\"user\">2&#46; Adding GridDB Users and Granting DB Access<\/h3>\n<p>Next, we should create a new GridDB User. From the side panel, click the icon which says GridDB User. From this page, click <code>CREATE DATABASE USER<\/code>. This user&#8217;s name and password will be attached to all of our HTTP Requests as a Basic Authorization Header when using the Web API.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/create-user.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/create-user.png\" alt=\"\" width=\"3304\" height=\"2290\" class=\"aligncenter size-full wp-image-31284\" srcset=\"\/wp-content\/uploads\/2024\/12\/create-user.png 3304w, \/wp-content\/uploads\/2024\/12\/create-user-300x208.png 300w, \/wp-content\/uploads\/2024\/12\/create-user-1024x710.png 1024w, \/wp-content\/uploads\/2024\/12\/create-user-768x532.png 768w, \/wp-content\/uploads\/2024\/12\/create-user-1536x1065.png 1536w, \/wp-content\/uploads\/2024\/12\/create-user-2048x1419.png 2048w, \/wp-content\/uploads\/2024\/12\/create-user-600x416.png 600w\" sizes=\"(max-width: 3304px) 100vw, 3304px\" \/><\/a><\/p>\n<p>Once you create the new user, you will also need to grant access to your database. Click on the user from the table of users in GridDB Users page and from this page, grant access to your database (either READ or ALL). Now we can move on to making actual HTTP requests.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/grant-permissions.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/grant-permissions.png\" alt=\"\" width=\"3330\" height=\"1564\" class=\"aligncenter size-full wp-image-31278\" srcset=\"\/wp-content\/uploads\/2024\/12\/grant-permissions.png 3330w, \/wp-content\/uploads\/2024\/12\/grant-permissions-300x141.png 300w, \/wp-content\/uploads\/2024\/12\/grant-permissions-1024x481.png 1024w, \/wp-content\/uploads\/2024\/12\/grant-permissions-768x361.png 768w, \/wp-content\/uploads\/2024\/12\/grant-permissions-1536x721.png 1536w, \/wp-content\/uploads\/2024\/12\/grant-permissions-2048x962.png 2048w, \/wp-content\/uploads\/2024\/12\/grant-permissions-600x282.png 600w\" sizes=\"(max-width: 3330px) 100vw, 3330px\" \/><\/a><\/p>\n<h3 id=\"check-connection\">3&#46; Checking your GridDB Connection<\/h3>\n<p>Let&#8217;s start with a sanity check and make sure that we can reach out to the GridDB Cloud instance.<\/p>\n<p>With your <code>.env<\/code> file made and ready to go, you can make sure you get the variables loaded into your environment using the following command: <code>$ source .env<\/code>.<\/p>\n<p>And now run the bash script:<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/checkConnection.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/checkConnection.png\" alt=\"\" width=\"1033\" height=\"307\" class=\"aligncenter size-full wp-image-31283\" srcset=\"\/wp-content\/uploads\/2024\/12\/checkConnection.png 1033w, \/wp-content\/uploads\/2024\/12\/checkConnection-300x89.png 300w, \/wp-content\/uploads\/2024\/12\/checkConnection-1024x304.png 1024w, \/wp-content\/uploads\/2024\/12\/checkConnection-768x228.png 768w, \/wp-content\/uploads\/2024\/12\/checkConnection-600x178.png 600w\" sizes=\"(max-width: 1033px) 100vw, 1033px\" \/><\/a><\/p>\n<p>If you see a status code of 200, that&#8217;s good! That means your connection was succesful. If you are met with a status code of <code>403 Forbidden<\/code>, that likely means you have not whitelisted your machine&#8217;s IP Address in the network tab. Likewise, a returned code of <code>401 Unauthorized<\/code> likely means your credentials are incorrect &#8212; please make sure you use <code>user:pass<\/code> encoded into base64!<\/p>\n<h4>Check Connection URL Endpoint<\/h4>\n<p>The Web API uses a <code>base url<\/code> which we will use and expand upon to build out our requests. The base url looks like this:<\/p>\n<h3><code>https:\/\/cloud&lt;number&gt;.griddb.com\/griddb\/v2\/&lt;clusterName&gt;\/dbs\/&lt;database name&gt;<\/code><\/h3>\n<p>To check that our connection exists, we can append the following to our base url <code>\/checkConnection<\/code>. Because we are not sending any data back to the server, we will use the <code>GET<\/code> HTTP method.<\/p>\n<p>Lastly, we need to include <code>basic authentication<\/code> in our HTTP Request&#8217;s headers. For this, we will need to include our username and password encoded into base64. With all that said, here is the final result<\/p>\n<p><code>https:\/\/cloud51ergege97.griddb.com\/griddb\/v2\/gs_clustermfcloud51fgerge97\/dbs\/B2vderewDSJy\/checkConnection<\/code><\/p>\n<p>We can now use this URL with any number of programming languages to communicate with our database.<\/p>\n<p>And as a note, the examples in this article will contain the URLs and credentials hardcoded into the example, but the source code (linked above) uses environment variables.<\/p>\n<h4>cURL Request<\/h4>\n<p>To check our connection with cURL, you can use the following command (<code>check_connection.sh<\/code>)<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">curl -i --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/checkConnection' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'<\/code><\/pre>\n<\/div>\n<p>Because it&#8217;s a <code>GET<\/code> request, it&#8217;s rather simple and we only needed to add in the authorization header. You should be able to run this and get an HTTP Response of <code>200<\/code>.<\/p>\n<h4>Python Request<\/h4>\n<p>Here is that same request written in Python<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\"># check_connection.py\nimport requests\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/checkConnection\"\n\npayload = {}\nheaders = {\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.status_code)<\/code><\/pre>\n<\/div>\n<h4>node.js Request<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/checkConnection.js\nconst request = require('request');\nconst options = {\n  'method': 'GET',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/checkConnection',\n  'headers': {\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  }\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(\"Response Status Code: \", response.statusCode);\n});<\/code><\/pre>\n<\/div>\n<h3 id=\"first-container\">4&#46; Creating your First Time Series &amp; Collection Containers<\/h3>\n<p>With our connection firmly established, we can create our first containers &#8212; both Collection and Time Series &#8212; of which are similar to relational tables. You can read more about that here: <a href=\"https:\/\/docs.griddb.net\/architecture\/data-model.html\">GridDB Data Model<\/a>.<\/p>\n<p>The URL suffix looks like this: <code>\/containers<\/code>. This request can sometimes require a multitude of data and can have a big range, therefore this request will require an HTTP method of <code>POST<\/code>.<\/p>\n<p>The body of the request requires container name, container type, whether a rowkey exists (bool), and the schema. Let&#8217;s first take a look at the structure outside of the context of an HTTP Request and then we will send it inside of a Request body. We will also need to include in our Request&#8217;s headers that we are sending a data payload of type JSON like so: <code>'Content-Type: application\/json'<\/code><\/p>\n<h4>Time Series Container<\/h4>\n<p>First, let&#8217;s create a Time Series container &#8212; we can see here that we select the container type as TIME_SERIES and the first column is of type timestamp. There is also a rowkey section, but this is optional as in a time series container, the rowkey is always the timestamp by default.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">\n{\n    \"container_name\": \"device1\",\n    \"container_type\": \"TIME_SERIES\",\n    \"rowkey\": true,\n    \"columns\": [\n        {\n            \"name\": \"ts\",\n            \"type\": \"TIMESTAMP\"\n        },\n        {\n            \"name\": \"co\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"humidity\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"light\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"lpg\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"motion\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"smoke\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"temp\",\n            \"type\": \"DOUBLE\"\n        }\n    ]\n}<\/code><\/pre>\n<\/div>\n<p>Now we simply attach this to the body when we make our Request and we should create our new container. If successful, you should get a status code of <code>201 (Created)<\/code>.<\/p>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#create_container.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '{\n    \"container_name\": \"device1\",\n    \"container_type\": \"TIME_SERIES\",\n    \"rowkey\": true,\n    \"columns\": [\n        {\n            \"name\": \"ts\",\n            \"type\": \"TIMESTAMP\"\n        },\n        {\n            \"name\": \"co\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"humidity\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"light\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"lpg\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"motion\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"smoke\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"temp\",\n            \"type\": \"DOUBLE\"\n        }\n    ]\n}'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#create_container.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\"\n\npayload = json.dumps({\n  \"container_name\": \"device1\",\n  \"container_type\": \"TIME_SERIES\",\n  \"rowkey\": True,\n  \"columns\": [\n    {\n      \"name\": \"ts\",\n      \"type\": \"TIMESTAMP\"\n    },\n    {\n      \"name\": \"co\",\n      \"type\": \"DOUBLE\"\n    },\n    {\n      \"name\": \"humidity\",\n      \"type\": \"DOUBLE\"\n    },\n    {\n      \"name\": \"light\",\n      \"type\": \"BOOL\"\n    },\n    {\n      \"name\": \"lpg\",\n      \"type\": \"DOUBLE\"\n    },\n    {\n      \"name\": \"motion\",\n      \"type\": \"BOOL\"\n    },\n    {\n      \"name\": \"smoke\",\n      \"type\": \"DOUBLE\"\n    },\n    {\n      \"name\": \"temp\",\n      \"type\": \"DOUBLE\"\n    }\n  ]\n})\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.status_code)<\/code><\/pre>\n<\/div>\n<h5>node.js<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/createContainer.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify({\n    \"container_name\": \"device1\",\n    \"container_type\": \"TIME_SERIES\",\n    \"rowkey\": true,\n    \"columns\": [\n      {\n        \"name\": \"ts\",\n        \"type\": \"TIMESTAMP\"\n      },\n      {\n        \"name\": \"co\",\n        \"type\": \"DOUBLE\"\n      },\n      {\n        \"name\": \"humidity\",\n        \"type\": \"DOUBLE\"\n      },\n      {\n        \"name\": \"light\",\n        \"type\": \"BOOL\"\n      },\n      {\n        \"name\": \"lpg\",\n        \"type\": \"DOUBLE\"\n      },\n      {\n        \"name\": \"motion\",\n        \"type\": \"BOOL\"\n      },\n      {\n        \"name\": \"smoke\",\n        \"type\": \"DOUBLE\"\n      },\n      {\n        \"name\": \"temp\",\n        \"type\": \"DOUBLE\"\n      }\n    ]\n  })\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(\"Response Status Code: \", response.statusCode);\n});<\/code><\/pre>\n<\/div>\n<h4>Collection Container<\/h4>\n<p>Now let&#8217;s create a collection container. These containers don&#8217;t require a time series column (but they are allowed) and also don&#8217;t require rowkey to be set to true. Here are some examples:<\/p>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#create_collection.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '{\n    \"container_name\": \"deviceMaster\",\n    \"container_type\": \"COLLECTION\",\n    \"rowkey\": true,\n    \"columns\": [\n        {\n            \"name\": \"equipment\",\n            \"type\": \"STRING\"\n        },\n        {\n            \"name\": \"equipmentID\",\n            \"type\": \"STRING\"\n        },\n        {\n            \"name\": \"location\",\n            \"type\": \"STRING\"\n        },\n        {\n            \"name\": \"serialNumber\",\n            \"type\": \"STRING\"\n        },\n        {\n            \"name\": \"lastInspection\",\n            \"type\": \"TIMESTAMP\"\n        },\n        {\n            \"name\": \"information\",\n            \"type\": \"STRING\"\n        }\n    ]\n}'<\/code><\/pre>\n<\/div>\n<h4>Python<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#create_collection.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\"\n\npayload = json.dumps({\n  \"container_name\": \"deviceMaster\",\n  \"container_type\": \"COLLECTION\",\n  \"rowkey\": True,\n  \"columns\": [\n    {\n      \"name\": \"equipment\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"name\": \"equipmentID\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"name\": \"location\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"name\": \"serialNumber\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"name\": \"lastInspection\",\n      \"type\": \"TIMESTAMP\"\n    },\n    {\n      \"name\": \"information\",\n      \"type\": \"STRING\"\n    }\n  ]\n})\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.status_code)<\/code><\/pre>\n<\/div>\n<h4>node.js<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/createCollection.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify({\n    \"container_name\": \"deviceMaster\",\n    \"container_type\": \"COLLECTION\",\n    \"rowkey\": true,\n    \"columns\": [\n      {\n        \"name\": \"equipment\",\n        \"type\": \"STRING\"\n      },\n      {\n        \"name\": \"equipmentID\",\n        \"type\": \"STRING\"\n      },\n      {\n        \"name\": \"location\",\n        \"type\": \"STRING\"\n      },\n      {\n        \"name\": \"serialNumber\",\n        \"type\": \"STRING\"\n      },\n      {\n        \"name\": \"lastInspection\",\n        \"type\": \"TIMESTAMP\"\n      },\n      {\n        \"name\": \"information\",\n        \"type\": \"STRING\"\n      }\n    ]\n  })\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.statusCode);\n});<\/code><\/pre>\n<\/div>\n<h3>5&#46; CRUD with GridDB Cloud (Create, Read, Update, Delete)<\/h3>\n<h3 id=\"crud\">5&#46; CRUD with GridDB Cloud (Create, Read, Update, Delete)<\/h3>\n<p>Next, let&#8217;s go over the commands to Create, Read, Update, and Delete.<\/p>\n<h4>Adding Rows of Data (Create)<\/h4>\n<p>We have already created some containers before, but to add to that, we will be creating rows of data to add to our container. We can add rows of data directly inside of our containers. The URL suffix: <code>\/containers\/:container\/rows<\/code><\/p>\n<p>To <code>PUT<\/code> a row of data into our container, we will need to use the HTTP Method <code>PUT<\/code>. Similar to before, we will need to specify that our content is JSON and we will include the row data in our Request body.<\/p>\n<p>You can add multiple rows at once, you just need to make sure that your payload is formed to accomdate extra rows and that you don&#8217;t have a trailing comma on the last row.<\/p>\n<p>Let&#8217;s add rows to our <code>device1<\/code> container.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  [\"2024-01-09T10:00:01.234Z\", 0.003551, 50.0, false, 0.00754352, false, 0.0232432, 21.6],\n  [\"2024-01-09T11:00:01.234Z\", 0.303551, 60.0, false, 0.00754352, true, 0.1232432, 25.3],\n  [\"2024-01-09T12:00:01.234Z\", 0.603411, 70.0, true, 0.00754352, true, 0.4232432, 41.5]\n]<\/code><\/pre>\n<\/div>\n<p>You of course also need to be sure that your row&#8217;s schema matches your container&#8217;s. If it doesn&#8217;t, you will be met with an error message and a status code of <code>400 (Bad Request)<\/code>.<\/p>\n<h5>cURL<\/h5>\n<p>https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#add_rows.sh\ncurl --location --request PUT 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  [\"2024-01-09T10:00:01.234Z\", 0.003551, 50.0, false, 0.00754352, false, 0.0232432, 21.6],\n  [\"2024-01-09T11:00:01.234Z\", 0.303551, 60.0, false, 0.00754352, true, 0.1232432, 25.3],\n  [\"2024-01-09T12:00:01.234Z\", 0.603411, 70.0, true, 0.00754352, true, 0.4232432, 41.5]\n]'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#add_rows.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows\"\n\npayload = json.dumps([\n  [\n    \"2024-01-09T10:00:01.234Z\",\n    0.003551,\n    50,\n    False,\n    0.00754352,\n    False,\n    0.0232432,\n    21.6\n  ],\n  [\n    \"2024-01-09T11:00:01.234Z\",\n    0.303551,\n    60,\n    False,\n    0.00754352,\n    True,\n    0.1232432,\n    25.3\n  ],\n  [\n    \"2024-01-09T12:00:01.234Z\",\n    0.603411,\n    70,\n    True,\n    0.00754352,\n    True,\n    0.4232432,\n    41.5\n  ]\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h5>node.js<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/addRows.js\nvar request = require('request');\nvar options = {\n  'method': 'PUT',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    [\n      \"2024-01-09T10:00:01.234Z\",\n      0.003551,\n      50,\n      false,\n      0.00754352,\n      false,\n      0.0232432,\n      21.6\n    ],\n    [\n      \"2024-01-09T11:00:01.234Z\",\n      0.303551,\n      60,\n      false,\n      0.00754352,\n      true,\n      0.1232432,\n      25.3\n    ],\n    [\n      \"2024-01-09T12:00:01.234Z\",\n      0.603411,\n      70,\n      true,\n      0.00754352,\n      true,\n      0.4232432,\n      41.5\n    ]\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h4>Querying Container (Read)<\/h4>\n<p>After writing to our containers, we will want to read from our containers. The URL suffix is exactly the same as before: <code>\/:cluster\/dbs\/:database\/containers\/:container\/rows<\/code> except now we will be using the <code>POST<\/code> method request. The data expected by the server in these requests are how we expect our row data returned to us &#8212; for example, we can choose a row limit, an offset, any conditions, and a sort method. Here is what that body looks like:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">{\n  \"offset\" : 0,\n  \"limit\"  : 100,\n  \"condition\" : \"temp >= 30\",\n  \"sort\" : \"temp desc\"\n}<\/code><\/pre>\n<\/div>\n<p>The one caveat with making this Request is that because it is a <code>POST<\/code> request, you will need to send <em>something<\/em> in the body of the request. Any of the parameters above will do, but including the limit is likely the easiest option to include and has the added benefit of reducing server strain.<\/p>\n<p>If successful, you should get a server response with a status code of <code>200 (OK)<\/code> and a body with the data requested.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#query_container.sh\n{\n    \"columns\": [\n        {\n            \"name\": \"ts\",\n            \"type\": \"TIMESTAMP\",\n            \"timePrecision\": \"MILLISECOND\"\n        },\n        {\n            \"name\": \"co\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"humidity\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"light\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"lpg\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"motion\",\n            \"type\": \"BOOL\"\n        },\n        {\n            \"name\": \"smoke\",\n            \"type\": \"DOUBLE\"\n        },\n        {\n            \"name\": \"temp\",\n            \"type\": \"DOUBLE\"\n        }\n    ],\n    \"rows\": [\n        [\n            \"2024-01-09T12:00:01.234Z\",\n            0.603411,\n            70.0,\n            true,\n            0.00754352,\n            true,\n            0.4232432,\n            41.5\n        ]\n    ],\n    \"offset\": 0,\n    \"limit\": 100,\n    \"total\": 1\n}<\/code><\/pre>\n<\/div>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">curl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '{\n  \"offset\" : 0,\n  \"limit\"  : 100,\n  \"condition\" : \"temp >= 30\",\n  \"sort\" : \"temp desc\"\n}'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#query_container.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows\"\n\npayload = json.dumps({\n  \"offset\": 0,\n  \"limit\": 100,\n  \"condition\": \"temp >= 30\",\n  \"sort\": \"temp desc\"\n})\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h5>nodejs<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/queryContainer.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify({\n    \"offset\": 0,\n    \"limit\": 100,\n    \"condition\": \"temp >= 30\",\n    \"sort\": \"temp desc\"\n  })\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});\n<\/code><\/pre>\n<\/div>\n<h4>Updating a Row (Update)<\/h4>\n<p>To cover updates, adding rows of data can be considered updating, but we can also directly update a row (if the container has rowkeys). The way it works is if you push a row of data to your container which has rowkey set as true, and send up a row of data with a rowkey that already exists in your container, it will update the row with whatever new information is pushed along.<\/p>\n<p>Let&#8217;s push data to our <code>deviceMaster<\/code> collection container once to add data, and then again to update the row.<\/p>\n<p>Let&#8217;s craft our row of data<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  [\"device1\", \"01\", \"CA\", \"23412\", \"2023-12-15T10:45:00.032Z\", \"working\"]\n]<\/code><\/pre>\n<\/div>\n<p>Now let&#8217;s form our HTTP Requests<\/p>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#update_collection.sh\ncurl -i --location --request PUT 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  [\"device1\", \"01\", \"CA\", \"23412\", \"2023-12-15T10:45:00.032Z\", \"working\"]\n]'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#update_collection.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows\"\n\npayload = json.dumps([\n  [\n    \"device1\",\n    \"01\",\n    \"CA\",\n    \"23412\",\n    \"2023-12-15T10:45:00.032Z\",\n    \"working\"\n  ]\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h5>node.js<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/updateCollection.js\nvar request = require('request');\nvar options = {\n  'method': 'PUT',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    [\n      \"device1\",\n      \"01\",\n      \"CA\",\n      \"23412\",\n      \"2023-12-15T10:45:00.032Z\",\n      \"working\"\n    ]\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h4>Updating a Row<\/h4>\n<p>And now with that data in there, if you change any of the values outside of the first one (the rowkey, the device name), it will update that device&#8217;s metadata will keeping the row inside of your container.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">curl -i --location --request PUT 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  [\"device1\", \"01\", \"NY\", \"23412\", \"2023-12-20T10:45:00.032Z\", \"working\"]\n]'<\/code><\/pre>\n<\/div>\n<p>Here we are changing the location and the time of last inspection. If you look at your dashboard, the values will be have been updated.<\/p>\n<h4>Deleting a Row (Delete)<\/h4>\n<p>We can delete a row simply by using the appropriate HTTP Method (Delete) and then sending in a valid rowkey and container to our server. Let&#8217;s delete our deviceMaster&#8217;s lone row.<\/p>\n<p>The body of the request looks like this. You can add multiple rowkeys inside here to delete multiple rows at once.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  \"device1\"\n]<\/code><\/pre>\n<\/div>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#delete_row.sh\ncurl -v --location --request DELETE 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  \"device1\"\n]'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#delete_row.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows\"\n\npayload = json.dumps([\n  \"device1\"\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"DELETE\", url, headers=headers, data=payload)\n\nprint(response.status_code)<\/code><\/pre>\n<\/div>\n<h5>node.js<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/deleteRow.js\nvar request = require('request');\nvar options = {\n  'method': 'DELETE',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/deviceMaster\/rows',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    \"device1\"\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.statusCode);\n});<\/code><\/pre>\n<\/div>\n<h5>Deleting a Row from Time Series Container<\/h5>\n<p>You can also delete the row of a time series container. As stated before, the time stamp will always be the rowkey in a time series container, so here we just add our time stamp and those rows will be deleted.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#delete_container.sh\ncurl --location --request DELETE 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\/device1\/rows' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  \"2024-01-09T10:00:01.234Z\",\n  \"2024-01-09T12:00:01.234Z\"\n]'<\/code><\/pre>\n<\/div>\n<h3>TQL<\/h3>\n<p>Next, let&#8217;s try running a TQL Query. If you&#8217;re unfamiliar, TQL is GridDB&#8217;s special <a href=\"https:\/\/griddb.net\/en\/blog\/griddb-query-language\/\">query language<\/a>.<\/p>\n<p>Let&#8217;s run a simple query. First, this is what the URL looks like<\/p>\n<p>base url + <code>\/tql<\/code><\/p>\n<p>The body of the request will need the container name followed by your query statement. We can also query multiple containers at once:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  {\"name\" : \"deviceMaster\", \"stmt\" : \"select * limit 100\", \"columns\" : null},\n  {\"name\" : \"device1\", \"stmt\" : \"select * where temp>=24\", \"columns\" : [\"temp\", \"co\"]},\n]<\/code><\/pre>\n<\/div>\n<p>And this is the response of the above query:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n    {\n        \"columns\": [\n            {\n                \"name\": \"equipment\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"equipmentID\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"location\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"serialNumber\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"lastInspection\",\n                \"type\": \"TIMESTAMP\",\n                \"timePrecision\": \"MILLISECOND\"\n            },\n            {\n                \"name\": \"information\",\n                \"type\": \"STRING\"\n            }\n        ],\n        \"results\": [\n            [\n                \"device1\",\n                \"01\",\n                \"NY\",\n                \"23412\",\n                \"2023-12-20T10:45:00.032Z\",\n                \"working\"\n            ]\n        ],\n        \"offset\": 0,\n        \"limit\": 100,\n        \"total\": 1,\n        \"responseSizeByte\": 31\n    },\n    {\n        \"columns\": [\n            {\n                \"name\": \"temp\",\n                \"type\": \"DOUBLE\"\n            },\n            {\n                \"name\": \"co\",\n                \"type\": \"DOUBLE\"\n            }\n        ],\n        \"results\": [\n            [\n                25.3,\n                0.303551\n            ],\n            [\n                41.5,\n                0.603411\n            ]\n        ],\n        \"offset\": 0,\n        \"limit\": 1000000,\n        \"total\": 2,\n        \"responseSizeByte\": 32\n    }\n]<\/code><\/pre>\n<\/div>\n<h4>cURL<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#tql.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/tql' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '\n[\n  {\"name\" : \"deviceMaster\", \"stmt\" : \"select * limit 100\", \"columns\" : null},\n  {\"name\" : \"device1\", \"stmt\" : \"select * where temp>=24\", \"columns\" : [\"temp\", \"co\"]}\n]\n'<\/code><\/pre>\n<\/div>\n<h4>Python<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#tql.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/tql\"\n\npayload = json.dumps([\n  {\n    \"name\": \"deviceMaster\",\n    \"stmt\": \"select * limit 100\",\n    \"columns\": None\n  },\n  {\n    \"name\": \"device1\",\n    \"stmt\": \"select * where temp>=24\",\n    \"columns\": [\n      \"temp\",\n      \"co\"\n    ]\n  }\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h4>node.js<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/tql.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/tql',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    {\n      \"name\": \"deviceMaster\",\n      \"stmt\": \"select * limit 100\",\n      \"columns\": null\n    },\n    {\n      \"name\": \"device1\",\n      \"stmt\": \"select * where temp>=24\",\n      \"columns\": [\n        \"temp\",\n        \"co\"\n      ]\n    }\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h3>SQL<\/h3>\n<p>On top of TQL, GridDB and the GridDB Cloud also have SQL functionality. Though the SQL functionality for the GridDB Cloud is limited to reading results (SELECT) and updating some rows (UPDATE).<\/p>\n<h4>SQL SELECT<\/h4>\n<p>base url + <code>\/sql<\/code><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT * FROM deviceMaster\"},\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT temp, co FROM device1 WHERE temp>=24\"}\n]<\/code><\/pre>\n<\/div>\n<p>It is very similar to TQL but we call on the container name from within the query itself, just like &#8220;normal&#8221; SQL statements.<\/p>\n<p>Here is the response body:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n    {\n        \"columns\": [\n            {\n                \"name\": \"equipment\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"equipmentID\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"location\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"serialNumber\",\n                \"type\": \"STRING\"\n            },\n            {\n                \"name\": \"lastInspection\",\n                \"type\": \"TIMESTAMP\",\n                \"timePrecision\": \"MILLISECOND\"\n            },\n            {\n                \"name\": \"information\",\n                \"type\": \"STRING\"\n            }\n        ],\n        \"results\": [\n            [\n                \"device1\",\n                \"01\",\n                \"CA\",\n                \"23412\",\n                \"2023-12-15T10:45:00.032Z\",\n                \"working\"\n            ]\n        ],\n        \"responseSizeByte\": 47\n    },\n    {\n        \"columns\": [\n            {\n                \"name\": \"temp\",\n                \"type\": \"DOUBLE\"\n            },\n            {\n                \"name\": \"co\",\n                \"type\": \"DOUBLE\"\n            }\n        ],\n        \"results\": [\n            [\n                25.3,\n                0.303551\n            ],\n            [\n                41.5,\n                0.603411\n            ]\n        ],\n        \"responseSizeByte\": 32\n    }\n]<\/code><\/pre>\n<\/div>\n<h4>cURL<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#sql_select.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT * FROM deviceMaster\"},\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT temp, co FROM device1 WHERE temp>=24\"}\n]\n'<\/code><\/pre>\n<\/div>\n<h4>Python<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#sql_select.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\"\n\npayload = json.dumps([\n  {\n    \"type\": \"sql-select\",\n    \"stmt\": \"SELECT * FROM deviceMaster\"\n  },\n  {\n    \"type\": \"sql-select\",\n    \"stmt\": \"SELECT temp, co FROM device1 WHERE temp>=24\"\n  }\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h4>node.js<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/sqlSelect.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    {\n      \"type\": \"sql-select\",\n      \"stmt\": \"SELECT * FROM deviceMaster\"\n    },\n    {\n      \"type\": \"sql-select\",\n      \"stmt\": \"SELECT temp, co FROM device1 WHERE temp>=24\"\n    }\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h4>SQL SELECT GROUP BY RANGE<\/h4>\n<p>Because we are using SQL Select, you can use the GridDB&#8217;s Group By Range as well. You can learn more about that here: <a href=\"https:\/\/griddb.net\/en\/blog\/exploring-griddbs-group-by-range-functionality\/\">Exploring GridDB\u00e2\u0080\u0099s Group By Range Functionality<\/a>.<\/p>\n<p>We will make our query and group by hours:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT temp, co FROM device1 WHERE ts > TO_TIMESTAMP_MS(1594515625984) AND ts &lt; TO_TIMESTAMP_MS(1595040779336) GROUP BY RANGE (ts) EVERY (1, HOUR)\"}\n]<\/code><\/pre>\n<\/div>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#sql_select_groupby.sh\ncurl -i --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  {\"type\" : \"sql-select\", \"stmt\" : \"SELECT temp, co FROM device1 WHERE ts > TO_TIMESTAMP_MS(1594515625984) AND ts &lt; TO_TIMESTAMP_MS(1595040779336) GROUP BY RANGE (ts) EVERY (1, HOUR)\"}\n]\n'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\"># sql_select_groupby.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\"\n\npayload = json.dumps([\n  {\n    \"type\": \"sql-select\",\n    \"stmt\": \"SELECT temp, co FROM device1 WHERE ts > TO_TIMESTAMP_MS(1594515625984) AND ts &lt; TO_TIMESTAMP_MS(1595040779336) GROUP BY RANGE (ts) EVERY (1, HOUR)\"\n  }\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h4>SQL Insert<\/h4>\n<p>The base URL is the same as SELECT, but you need to append &#8216;update&#8217;<\/p>\n<p>base url + <code>\/:cluster\/dbs\/:database\/sql\/update<\/code><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[ \n  {\"stmt\" : \"insert into deviceMaster(equipment, equipmentID, location, serialNumber, lastInspection, information) values('device2', '02', 'MA', '34412', TIMESTAMP('2023-12-21T10:45:00.032Z'), 'working')\"}\n]<\/code><\/pre>\n<\/div>\n<h6>cURL<\/h6>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#sql_insert.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[ \n  {\"stmt\" : \"insert into deviceMaster(equipment, equipmentID, location, serialNumber, lastInspection, information) values('''device2''', '''02''', '''MA''', '''34412''', TIMESTAMP('''2023-12-21T10:45:00.032Z'''), '''working''')\"}\n]'<\/code><\/pre>\n<\/div>\n<h6>Python<\/h6>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#sql_insert.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update\"\n\npayload = json.dumps([\n  {\n    \"stmt\": \"insert into deviceMaster(equipment, equipmentID, location, serialNumber, lastInspection, information) values('device2', '02', 'MA', '34412', TIMESTAMP('2023-12-21T10:45:00.032Z'), 'working')\"\n  }\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h6>node.js<\/h6>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/sqlInsert.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    {\n      \"stmt\": \"insert into deviceMaster(equipment, equipmentID, location, serialNumber, lastInspection, information) values('device2', '02', 'MA', '34412', TIMESTAMP('2023-12-21T10:45:00.032Z'), 'working')\"\n    }\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h4>SQL Update<\/h4>\n<p>The base URL is the same as above, but you need to append &#8216;update&#8217;<\/p>\n<p>base url + <code>\/sql\/update<\/code><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[ \n  {\"stmt\" : \"update deviceMaster set location = 'LA' where equipmentID = '01'\"}\n]<\/code><\/pre>\n<\/div>\n<p>This command allows you to Update, similar to the NoSQL method described above. We can both update existing rows, or update containers to add new rows.<\/p>\n<h5>cURL<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#sql_update.sh\ncurl -i -X POST --location 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[ \n  {\"stmt\" : \"update deviceMaster set location = '''LA''' where equipmentID = '''01'''\"}\n]'<\/code><\/pre>\n<\/div>\n<h5>Python<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#sql_update.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update\"\n\npayload = json.dumps([\n  {\n    \"stmt\": \"update deviceMaster set location = 'LA' where equipmentID = '01'\"\n  }\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0' \n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)<\/code><\/pre>\n<\/div>\n<h5>node.js<\/h5>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/sqlUpdate.js\nvar request = require('request');\nvar options = {\n  'method': 'POST',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/sql\/update',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    {\n      \"stmt\": \"update deviceMaster set location = 'LA' where equipmentID = '01'\"\n    }\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});<\/code><\/pre>\n<\/div>\n<h3>Dropping Containers<\/h3>\n<p>We can also drop containers.<\/p>\n<p>base url + <code>\/containers<\/code><\/p>\n<p>The request&#8217;s body can contain one or multiple container names of which will be dropped once we make our request.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">[\n  \"deviceMaster\"\n]<\/code><\/pre>\n<\/div>\n<p>If successful, you will receive a status code of <code>204 (No Content)<\/code><\/p>\n<h4>cURL<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">#delete_container.sh\ncurl -i --location --request DELETE 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers' \n--header 'Content-Type: application\/json' \n--header 'Authorization: Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs' \n--data '[\n  \"deviceMaster\"\n]'<\/code><\/pre>\n<\/div>\n<h4>Python<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#delete_container.py\nimport requests\nimport json\n\nurl = \"https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers\"\n\npayload = json.dumps([\n  \"deviceMaster\"\n])\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  'User-Agent': 'PostmanRuntime\/7.29.0'\n}\n\nresponse = requests.request(\"DELETE\", url, headers=headers, data=payload)\n\nprint(response.status_code)<\/code><\/pre>\n<\/div>\n<h4>node.js<\/h4>\n<div class=\"clipboard\">\n<pre><code class=\"language-js\">\/\/deleteContainer.js\nvar request = require('request');\nvar options = {\n  'method': 'DELETE',\n  'url': 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/containers',\n  'headers': {\n    'Content-Type': 'application\/json',\n    'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs'\n  },\n  body: JSON.stringify([\n    \"deviceMaster\"\n  ])\n\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.statusCode);\n});<\/code><\/pre>\n<\/div>\n<h3 id=\"ingest\">6&#46; Ingesting Sample IoT Data<\/h3>\n<p>Next, let&#8217;s take a look at ingesting CSV data. We will ingest IoT data from Kaggle. You can download the raw file from their website here: <a href=\"https:\/\/www.kaggle.com\/datasets\/garystafford\/environmental-sensor-data-132k\">https:\/\/www.kaggle.com\/datasets\/garystafford\/environmental-sensor-data-132k<\/a>.<\/p>\n<p>Here is the python script you can use to ingest the data into our <code>device2<\/code> container.<\/p>\n<p>We have already created our <code>device1<\/code> container, but we will use the same schema to create a new container called <code>device2<\/code><\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#data_ingest.py\nimport pandas as pd\nimport numpy as np\nimport json\nimport requests\nfrom datetime import datetime as dt, timezone\n\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  \"User-Agent\":\"PostmanRuntime\/7.29.0\"\n}\n\nbase_url = 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/'\n\ndata_obj = {\n    \"container_name\": \"device1\",\n    \"container_type\": \"TIME_SERIES\",\n    \"rowkey\": True,\n    \"columns\": []\n}\ninput_variables = [\n    \"ts\",\"co\",\"humidity\",\"light\",\"lpg\",\"motion\",\"smoke\",\"temp\"\n]\ndata_types = [\n    \"TIMESTAMP\", \"DOUBLE\", \"DOUBLE\", \"BOOL\", \"DOUBLE\", \"BOOL\", \"DOUBLE\",\"DOUBLE\"\n]\n\nfor variable, data_type in zip(input_variables, data_types):\n    column = {\n        \"name\": variable,\n        \"type\": data_type\n    }\n    data_obj[\"columns\"].append(column)\n\n#Create Container\nurl = base_url + 'containers'\nr = requests.post(url, json = data_obj, headers = headers)<\/code><\/pre>\n<\/div>\n<p>All of this is pretty straightforward.<\/p>\n<p>Next, let&#8217;s actually ingest the data. To do so, we will use the pandas python library to read the csv file which we will include inside of our body&#8217;s request to be ingested. The pandas library also allows us to easily target and transform specific columns in our csv data to make it possible to be ingested.<\/p>\n<p>And one last note, because the csv file is over eight megabytes, we will break up our data into chunks and send them to our Cloud that way. Download data from here: <a href=\"https:\/\/www.kaggle.com\/datasets\/garystafford\/environmental-sensor-data-132k\">https:\/\/www.kaggle.com\/datasets\/garystafford\/environmental-sensor-data-132k<\/a><\/p>\n<p>Here is the rest of the code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">iot_data = pd.read_csv('iot_telemetry_data.csv')\n\n#2023-12-15T10:25:00.253Z\niot_data['ts'] = pd.to_datetime(iot_data['ts'], unit='s').dt.strftime(\"%Y-%m-%dT%I:%M:%S.%fZ\")\nprint(iot_data[\"ts\"])\niot_data = iot_data.drop('device', axis=1)\n#print(iot_data.dtypes)\n\niot_subsets = np.array_split(iot_data, 20)\n\n#Ingest Data\nurl = base_url + 'containers\/device1\/rows'\n\nfor subset in  iot_subsets:\n    #Convert the data in the dataframe to the JSON format\n    iot_subsets_json = subset.to_json(orient='values')\n\n    request_body_subset = iot_subsets_json\n    r = requests.put(url, data=request_body_subset, headers=headers)\n    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')\n    print('_______________',r.text,'___________')\n    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')\n    if r.status_code > 299: \n        print(r.status_code)\n        break\n    else:\n        print('Success for chunk')\n<\/code><\/pre>\n<\/div>\n<p>As you run the script, it should be printing our successful messages for each chunk uploaded, complete with how many rows got successfully updated. Once done, you can check out your <code>device1<\/code> with an HTTP Request query or through the portal.<\/p>\n<h3 id=\"analysis\">7&#46; Running Data Analysis<\/h3>\n<p>Lastly, let&#8217;s do some simple python analysis. We will query our iot data and then use that data to do some simple analysis and charting of our data.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-python\">#data_analysis.py\nimport pandas as pd\nimport numpy as np\nimport requests\nimport plotly.express as px\nfrom IPython.display import Image \n\n# ts           object\n# co          float64\n# humidity    float64\n# light          bool\n# lpg         float64\n# motion         bool\n# smoke       float64\n# temp        float64\n\n\nheaders = {\n  'Content-Type': 'application\/json',\n  'Authorization': 'Basic TTAxMU1sd0MxYS1pc3ewrwqJhZWw6aXNyYWVs',\n  \"User-Agent\":\"PostmanRuntime\/7.29.0\"\n}\nbase_url = 'https:\/\/cloud5197422.griddb.com\/griddb\/v2\/gs_clustermfcloud5197422\/dbs\/B2vdfewfwDSJy\/'\n\nsql_query1 = (f\"\"\"SELECT * from device1 WHERE co &lt; 0.0019050147565559603 \"\"\")\n\nurl = base_url + 'sql'\nrequest_body = '[{\"type\":\"sql-select\", \"stmt\":\"'+sql_query1+'\"}]'\n\n\ndata_req1 = requests.post(url, data=request_body, headers=headers)\nmyJson = data_req1.json()\n\ndataset = pd.DataFrame(myJson[0][\"results\"],columns=[myJson[0][\"columns\"][0][\"name\"],myJson[0][\"columns\"][1][\"name\"],myJson[0][\"columns\"][2][\"name\"],\nmyJson[0][\"columns\"][3][\"name\"],myJson[0][\"columns\"][4][\"name\"],myJson[0][\"columns\"][5][\"name\"],myJson[0][\"columns\"][6][\"name\"],myJson[0][\"columns\"][7][\"name\"]])\n\nprint(dataset)\n\nlowest_col = dataset.sort_values('co', ascending=False).head(20000)\n\nscatter_plot = px.scatter(lowest_col, x='ts', y='co', size='co', color='co',\n                          color_continuous_scale='plasma', hover_name='co')\n# Customize the plot\nscatter_plot.update_layout(\n    title='Data Analysis',\n    xaxis_title='CO2 Emissions',\n    yaxis_title='Time'\n)\n\nscatter_plot.update_layout(template='plotly_dark')\n\n\n# Show the plot\nscatter_plot.show()<\/code><\/pre>\n<\/div>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/python_chart.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/12\/python_chart.png\" alt=\"\" width=\"1733\" height=\"801\" class=\"aligncenter size-full wp-image-31281\" srcset=\"\/wp-content\/uploads\/2024\/12\/python_chart.png 1733w, \/wp-content\/uploads\/2024\/12\/python_chart-300x139.png 300w, \/wp-content\/uploads\/2024\/12\/python_chart-1024x473.png 1024w, \/wp-content\/uploads\/2024\/12\/python_chart-768x355.png 768w, \/wp-content\/uploads\/2024\/12\/python_chart-1536x710.png 1536w, \/wp-content\/uploads\/2024\/12\/python_chart-600x277.png 600w\" sizes=\"(max-width: 1733px) 100vw, 1733px\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>And with that, we have shown you how to interact with your GridDB Cloud and do all sorts of database-related functions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how to insert IoT data into the GridDB Cloud, learn how to test the viability of your connection, and learn the basic CRUD commands (Create, Read, Update, Delete). Contents 0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":31301,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46820","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-19T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:57:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"516\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Israel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Israel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"29 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\"},\"author\":{\"name\":\"Israel\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/c8a430e7156a9e10af73b1fbb46c2740\"},\"headline\":\"GridDB Cloud Quick Start Guide\",\"datePublished\":\"2024-12-19T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:57:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\"},\"wordCount\":2443,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\",\"name\":\"GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png\",\"datePublished\":\"2024-12-19T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:57:12+00:00\",\"description\":\"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png\",\"contentUrl\":\"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png\",\"width\":1280,\"height\":516},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/c8a430e7156a9e10af73b1fbb46c2740\",\"name\":\"Israel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4df8cfc155402a2928d11f80b0220037b8bd26c4f1b19c4598d826e0306e6307?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4df8cfc155402a2928d11f80b0220037b8bd26c4f1b19c4598d826e0306e6307?s=96&d=mm&r=g\",\"caption\":\"Israel\"},\"url\":\"https:\/\/www.griddb.net\/en\/author\/israel\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT","description":"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/","og_locale":"en_US","og_type":"article","og_title":"GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT","og_description":"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how","og_url":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2024-12-19T08:00:00+00:00","article_modified_time":"2025-11-13T20:57:12+00:00","og_image":[{"width":1280,"height":516,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png","type":"image\/png"}],"author":"Israel","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"Israel","Est. reading time":"29 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/"},"author":{"name":"Israel","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/c8a430e7156a9e10af73b1fbb46c2740"},"headline":"GridDB Cloud Quick Start Guide","datePublished":"2024-12-19T08:00:00+00:00","dateModified":"2025-11-13T20:57:12+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/"},"wordCount":2443,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/","url":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/","name":"GridDB Cloud Quick Start Guide | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png","datePublished":"2024-12-19T08:00:00+00:00","dateModified":"2025-11-13T20:57:12+00:00","description":"GridDB Cloud v2.0 has officially been released, has a new free tier, and is officially available worldwide. In this quick start guide, you will learn how","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/#primaryimage","url":"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png","contentUrl":"\/wp-content\/uploads\/2024\/12\/\u753b\u50cf.png","width":1280,"height":516},{"@type":"WebSite","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/c8a430e7156a9e10af73b1fbb46c2740","name":"Israel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4df8cfc155402a2928d11f80b0220037b8bd26c4f1b19c4598d826e0306e6307?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4df8cfc155402a2928d11f80b0220037b8bd26c4f1b19c4598d826e0306e6307?s=96&d=mm&r=g","caption":"Israel"},"url":"https:\/\/www.griddb.net\/en\/author\/israel\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46820"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46820\/revisions"}],"predecessor-version":[{"id":51479,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/46820\/revisions\/51479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media\/31301"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}