{"id":50748,"date":"2021-03-12T00:00:00","date_gmt":"2021-03-12T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/"},"modified":"2025-11-14T07:54:42","modified_gmt":"2025-11-14T15:54:42","slug":"build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/","title":{"rendered":"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9"},"content":{"rendered":"<p>\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u307f\u7d42\u3048\u308b\u9803\u306b\u306f\u3001\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u4e3b\u8981\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3064\u3044\u3066\u5b66\u3073\u3001\u8a18\u4e8b\u306eFastAPI\u5b9f\u88c5\u4f8b\u3092\u3055\u3089\u306b\u62e1\u5f35\u3057\u3066\u81ea\u5206\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u9069\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u8b70\u8ad6\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306b\u3001\u3053\u306e\u30d6\u30ed\u30b0\u30a8\u30f3\u30c8\u30ea\u3067\u306f\u3001\u4e3b\u306b\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u69cb\u7bc9\u3068\u305d\u306e\u69d8\u3005\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u7d71\u5408\u306b\u7126\u70b9\u3092\u5f53\u3066\u3066\u3044\u307e\u3059\u3002IoT\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306b\u3064\u3044\u3066\u306f\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u305b\u3093\u304c\u3001\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u81ea\u4f53\u306e\u30b7\u30fc\u30e0\u30ec\u30b9\u306a\u4e00\u90e8\u306b\u3059\u308b\u305f\u3081\u306e\u624b\u9806\u306b\u3064\u3044\u3066\u3082\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"#source-code\"> \u5168\u3066\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9 <\/a><\/p>\n<h2>\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u6982\u8981<\/h2>\n<p>\u307e\u305a\u3001\u3053\u308c\u304b\u3089\u5b9f\u88c5\u3059\u308b\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u4f8b\u306e\u5168\u4f53\u50cf\u3092\u628a\u63e1\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306f3\u3064\u306e\u4e3b\u8981\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\uff1a\u6e29\u5ea6\u3001\u6c17\u5727\u3001\u6e7f\u5ea6\u3092\u76e3\u8996\u3059\u308b\u305f\u3081\u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u3068\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<li>GridDB\u30b5\u30fc\u30d0\uff1a\u6c17\u8c61\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/li>\n<li>FastAPI \u30a2\u30d7\u30ea\uff1aAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3001\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u5c64\u3001\u304a\u3088\u3073\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3057\u3066\u8fd4\u3059\u305f\u3081\u306e\u305d\u306e\u4ed6\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u3053\u306e\u8a2d\u5b9a\u3067\u306f\u3001FastAPI\u30a2\u30d7\u30ea\u306f\u30a6\u30a7\u30d6\u304b\u3089\u306e\u53d7\u4fe1 HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u3001\u30bb\u30f3\u30b5\u30fc\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3059\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u3084\u3001GridDB\u304b\u3089\u4fdd\u5b58\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u307e\u305f\u3001FastAPI\u30a2\u30d7\u30ea\u306f\u3001\u30c7\u30fc\u30bf\u306e\u89e3\u6790\u3001\u691c\u8a3c\u3001\u304a\u3088\u3073\u51e6\u7406\u306a\u3069\u3001\u305d\u306e\u4ed6\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u3084\u30b5\u30fc\u30d3\u30b9\u3092\u5b9f\u884c\u3059\u308b\u5834\u6240\u3067\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u306e\u5f8c\u534a\u3067\u306f\u3001\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u9069\u3057\u305f\u4ed6\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u30c7\u30b6\u30a4\u30f3\u306b\u3064\u3044\u3066\u3082\u8aac\u660e\u3057\u307e\u3059\u3002\u4eca\u306e\u3068\u3053\u308d\u3001\u3053\u306e\u30c7\u30b6\u30a4\u30f3\u3092\u4f7f\u3063\u3066\u3001FastAPI\u3068GridDB\u3092\u3046\u307e\u304f\u7d71\u5408\u3059\u308b\u65b9\u6cd5\u306e\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>\u8981\u4ef6\u3068\u8a2d\u5b9a<\/h2>\n<p>\u305d\u308c\u3067\u306f\u3001\u4eca\u56de\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u304a\u3051\u308b\u3059\u3079\u3066\u306e\u8981\u4ef6\u3068\u3001\u305d\u306e\u8a2d\u5b9a\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3<\/h3>\n<p>\u3053\u3053\u3067\u306f\u3001\u6e29\u5ea6\u3001\u6c17\u5727\u3001\u6e7f\u5ea6\u306e3\u3064\u306e\u7269\u7406\u91cf\u3092\u6e2c\u5b9a\u30fb\u76e3\u8996\u3059\u308b\u4eee\u60f3\u7684\u306aIoT\u30db\u30fc\u30e0\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u30bb\u30f3\u30b5\u30fc\u306fRaspberry Pi\u306b\u63a5\u7d9a\u3055\u308c\u3066\u304a\u308a\u3001Raspberry Pi\u306fGridDB\u30b5\u30fc\u30d0\u30fc\u3068FastAPI\u30a2\u30d7\u30ea\u3092\u5b9f\u884c\u3059\u308b\u30de\u30b7\u30f3\u3068\u3057\u3066\u3082\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n<p>\u524d\u8ff0\u306e\u901a\u308a\u3001\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u65b9\u6cd5\u306f\u3053\u3053\u3067\u306f\u8aac\u660e\u3057\u307e\u305b\u3093\u3002\u307e\u305f\u3001\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u8a2d\u5b9a\u306f\u3001\u5225\u306e\u3082\u306e\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u91cd\u8981\u306a\u3053\u3068\u306f\u3001\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306b\u9069\u5207\u306b\u7d71\u5408\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30bb\u30f3\u30b5\u30fc\u7528\u306e\u3059\u3079\u3066\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3001FastAPI\u30a2\u30d7\u30ea\u306ePython\u30b3\u30fc\u30c9\u304b\u3089\u898b\u3048\u308b\u74b0\u5883\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<a href=\"https:\/\/learn.adafruit.com\/dht\/overview\">DHT22 \u6e29\u5ea6\u30fb\u6c17\u5727\u30bb\u30f3\u30b5\u30fc<\/a>\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u3001<code>import Adafruit_DHT<\/code> \u30b3\u30de\u30f3\u30c9\u306f <code>ImportError<\/code> \u3092\u767a\u751f\u3055\u305b\u306a\u3044\u306f\u305a\u3067\u3059\u3002<\/p>\n<h3>GridDB\u30b5\u30fc\u30d0\u30fc<\/h3>\n<p>GridDB\u306f\u3001\u6c17\u8c61IoT\u30b7\u30b9\u30c6\u30e0\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u3057\u3066\u9069\u3057\u3066\u3044\u307e\u3059\u3002IoT\u5411\u3051\u306b\u6700\u9069\u5316\u3055\u308c\u3066\u304a\u308a\u3001\u591a\u304f\u306e\u6709\u7528\u306a\u6642\u7cfb\u5217\u6a5f\u80fd\u3092\u3059\u3050\u306b\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>GridDB\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/griddb.net\/ja\/blog\/griddb-on-arm-time-series-database-for-your-raspberry-pi\/\">Raspberry Pi\u4e0a\u3067ARM\u7528\u306eGridDB\u3068\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5<\/a>\u306e\u30ac\u30a4\u30c9\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001\u3059\u3050\u306b\u8d77\u52d5\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u9069\u5207\u306a<a href=\"https:\/\/griddb.net\/ja\/blog\/improve-your-devops-with-griddb-server-and-client-docker-containers\/\">GridDB Docker\u30a4\u30e1\u30fc\u30b8<\/a>\u3092\u30d3\u30eb\u30c9\u3057\u3066\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001GridDB\u30b3\u30f3\u30c6\u30ca\u3092\u4f7f\u3063\u3066\u3001\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u3092\u9069\u5207\u306a\u30ab\u30e9\u30e0\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\uff08TIMESTAMP\u578b\uff09<\/li>\n<li>\u6e29\u5ea6\uff08DOUBLE\u578b\uff09<\/li>\n<li>\u5727\u529b\uff08DOUBLE\u578b\uff09<\/li>\n<li>\u6e7f\u5ea6\uff08DOUBLE\u578b\uff09<\/li>\n<\/ul>\n<p>GridDB\u3068\u5bfe\u8a71\u3059\u308b\u305f\u3081\u306b\u3001FastAPI\u30a2\u30d7\u30ea\u306f<a href=\"https:\/\/github.com\/griddb\/python_client\">GridDB Python\u30af\u30e9\u30a4\u30a2\u30f3\u30c8<\/a>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002GridDB Python\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u3001<a href=\"https:\/\/griddb.net\/ja\/blog\/python-client\/\">\u3053\u306e\u30ac\u30a4\u30c9\u3092\u4f7f\u7528\u3057\u3066\u69cb\u7bc9\u304a\u3088\u3073\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a>\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>FastAPI\u30a2\u30d7\u30ea<\/h3>\n<p>FastAPI\u306f\u3001Web API\u3092\u8fc5\u901f\u306b\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306e<a href=\"https:\/\/fastapi.tiangolo.com\/\">\u9ad8\u6027\u80fd\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/a>\u3067\u3059\u3002\u4f7f\u3044\u3084\u3059\u304f\u3001\u4ed6\u306ePython\u30a6\u30a7\u30d6\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u6bd4\u8f03\u3057\u3066\u3001FastAPI\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3068\u958b\u767a\u671f\u9593\u304c\u77ed\u7e2e\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>FastAPI\u3092pip\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ pip install fastapi<\/code><\/p>\n<p>\u307e\u305f\u3001\u672c\u756a\u74b0\u5883\u3067\u30a2\u30d7\u30ea\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306eASGI\u30b5\u30fc\u30d0\u30fc\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ pip install uvicorn[standard]<\/code><\/p>\n<p>FastAPI\u30a2\u30d7\u30ea\u306e\u3055\u307e\u3056\u307e\u306a\u90e8\u5206\u3067\u61f8\u5ff5\u4e8b\u9805\u3092\u78ba\u5b9f\u306b\u5206\u96e2\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u3069\u306e\u3088\u3046\u306b\u69cb\u6210\u3059\u308b\u304b\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<pre><code>    .\n    |   .dockerignore\n    |   Dockerfile\n    |   init_griddb.py\n    |   requirements.txt\n    |   run.sh\n    |   \n    ---app\n        |   main.py\n        |   __init__.py\n        |   \n        +---config\n        |       base.py\n        |       __init__.py\n        |       \n        +---db\n        |       connection.py\n        |       utils.py\n        |       __init__.py\n        |       \n        +---schema\n        |       response.py\n        |       __init__.py\n        |       \n        ---services\n                weatherstation.py\n                __init__.py\n<\/code><\/pre>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4e3b\u8981\u306a\u30d5\u30a1\u30a4\u30eb\u3068\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u6982\u8981\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>.\/init_griddb.py \u306f GridDB \u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3059\u308b\u30b9\u30bf\u30f3\u30c9\u30a2\u30ed\u30f3\u306e Python \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/li>\n<li>.\/run.sh \u306f GridDB \u306e\u521d\u671f\u5316\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3001uvicorn \u30b5\u30fc\u30d0\u30fc\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n<li>.\/app\/main.py \u306f\u3001FastAPI \u30a2\u30d7\u30ea\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3068\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u5b9a\u7fa9\u3068\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/li>\n<li>.\/app\/config\/ \u306f\u3001\u8a2d\u5b9a\u3068\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u542b\u307f\u307e\u3059\u3002<\/li>\n<li>.app\/db\/ \u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u30ec\u30a4\u30e4\u30fc\u3067\u3059\u3002<\/li>\n<li>.app\/schema\/ \u306f\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u304c\u6b63\u3057\u3044\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3067\u3042\u308b\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b pydantic \u30e2\u30c7\u30eb\u3092\u542b\u307f\u307e\u3059\u3002<\/li>\n<li>.app\/services\/ \u306f\u3001\u30a2\u30d7\u30ea\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\uff08\u30bb\u30f3\u30b5\u30fc\u306e\u8d77\u52d5\u3084\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u306a\u3069\uff09\u3092\u542b\u307f\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u5f8c\u307b\u3069\u3001\u3053\u308c\u3089\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3067\u679c\u305f\u3059\u5f79\u5272\u306b\u3064\u3044\u3066\u3001\u3088\u308a\u8a73\u3057\u304f\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3<\/h2>\n<p>FastAPI\u30a2\u30d7\u30ea\u306f\u3001\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u3055\u307e\u3056\u307e\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u7d50\u3073\u3064\u3051\u307e\u3059\u3002\u305d\u306e\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30f3\u30d5\u30a3\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3<\/h3>\n<p>\u30a2\u30d7\u30ea\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306e\u5024\u306f\u3001<code>.\/app\/config\/<\/code>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u306b\u8aad\u307f\u8fbc\u307e\u308c\u305f\u308a\u3001\u5b9a\u7fa9\u3055\u308c\u305f\u308a\u3057\u307e\u3059\u3002<code>.\/app\/config\/base.py<\/code>\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\nimport os\n\nGRIDDB_CONNECTION_PARAMS = {\n    \"notification_member\": os.environ.get(\n        \"GRIDDB_NOTIFICATION_MEMBER\",\n        \"griddb-server:10001\"\n    ),\n    \"cluster_name\": os.environ.get(\"GRIDDB_CLUSTER_NAME\", \"defaultCluster\"),\n    \"username\": os.environ.get(\"GRIDDB_USERNAME\", \"admin\"),\n    \"password\": os.environ.get(\"GRIDDB_PASSWORD\", \"admin\"),\n}\nGRIDDB_CONTAINER_NAME = os.environ.get(\n    \"GRIDDB_CONTAINER_NAME\",\n    \"weatherstation\"\n)\n  <\/code><\/pre>\n<\/div>\n<p>\u6ce8\u610f\u3059\u3079\u304d\u70b9\u306f\u3001\u8a2d\u5b9a\u306e\u5024\u304c\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u6e21\u3055\u308c\u308b\u3053\u3068\u3067\u3059\u3002\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u5229\u7528\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a8d\u8a3c\u60c5\u5831\u306a\u3069\u306e\u6a5f\u5bc6\u60c5\u5831\u3092\u30cf\u30fc\u30c9\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u3001\u8aa4\u3063\u3066\u30bd\u30fc\u30b9\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306b\u30b3\u30df\u30c3\u30c8\u3057\u3066\u3057\u307e\u3046\u3053\u3068\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4e0a\u8a18\u306e\u63a5\u7d9a\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3001\u56fa\u5b9a\u30ea\u30b9\u30c8\u65b9\u5f0f\u3067 GridDB \u30b9\u30c8\u30a2\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044 \u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4ed6\u306e\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001\u30de\u30eb\u30c1\u30ad\u30e3\u30b9\u30c8\u65b9\u5f0f\u3084\u30d7\u30ed\u30d0\u30a4\u30c0\u65b9\u5f0f\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u308c\u305e\u308c\u7570\u306a\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u30bb\u30c3\u30c8\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h3>\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\uff08\u30b5\u30fc\u30d3\u30b9\u30ec\u30a4\u30e4\u30fc\uff09<\/h3>\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u306f\uff0c\u30a2\u30d7\u30ea\u3068\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u306e\u30a4\u30f3\u30bf\u30e9\u30af\u30b7\u30e7\u30f3\u306f\uff0c\u30d5\u30a1\u30a4\u30eb <code>.\/app\/services\/weatherstation.py<\/code> \u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u306f\uff0c\u3059\u3079\u3066\u306e\u30bb\u30f3\u30b5\u3092\u8d77\u52d5\u3057\u3066\u305d\u306e\u6e2c\u5b9a\u5024\u3092\u53d6\u5f97\u3059\u308b\u95a2\u6570 <code>get_sensor_data()<\/code> \u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\u3053\u306e\u95a2\u6570\u306f\u3001\u73fe\u5728\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3001\u6e29\u5ea6\u3001\u6c17\u5727\u3001\u6e7f\u5ea6\u3092\u542b\u3080\u8f9e\u66f8\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u7e70\u308a\u8fd4\u3057\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u3053\u3067\u306f\u4eee\u60f3\u7684\u306a\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u3053\u306e\u95a2\u6570\u306e\u5b9f\u88c5\u306b\u3064\u3044\u3066\u306f\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u305b\u3093\u3002\u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u306f\u3001.\/app\/services\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306f\u3001\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u306e\u30b3\u30fc\u30c9\u304c\u7f6e\u304b\u308c\u308b\u3079\u304d\u3060\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u3053\u3053\u306b\u306f\u3001\u30c7\u30fc\u30bf\u3092\u3055\u3089\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3084\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u30fc\u95a2\u6570\uff0f\u30af\u30e9\u30b9\u306a\u3069\u3001\u4ed6\u306e\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>GridDB\u30a2\u30af\u30bb\u30b9\u30ec\u30a4\u30e4\u30fc<\/h3>\n<p>\u6b21\u306b\u3001GridDB\u306e\u63a5\u7d9a\u3068\u30af\u30a8\u30ea\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u3068\u5c5e\u6027\u3092\u542b\u3080\u30af\u30e9\u30b9\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u306e\u30af\u30e9\u30b9\u306f\u3001.\/app\/db\/connection.py\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\nimport griddb_python as griddb\n\nfrom .utils import handle_exceptions\n\nclass GridDBConnection:\n    \"\"\"Convenience class for managing GridDB connection.\"\"\"\n\n    def __init__(self, connection_params: dict) -> None:\n        self.connection_params = connection_params\n        self.container_name = None\n        self.gridstore = None\n        self.container = None\n\n    @handle_exceptions\n    def init(self, container_name: str = None) -> None:\n        \"\"\"Sets gridstore and container instance.\"\"\"\n        factory = griddb.StoreFactory.get_instance()\n        self.gridstore = factory.get_store(**self.connection_params)\n        if container_name is not None:\n            self.container_name = container_name\n            self.container = self.gridstore.get_container(self.container_name)\n\n    @handle_exceptions\n    def create_container(self, container_info: griddb.ContainerInfo) -> None:\n        \"\"\"Creates container with given container info.\"\"\"\n        self.container_name = container_info.name\n        self.container = self.gridstore.put_container(container_info)\n\n    @handle_exceptions\n    def execute_and_fetch(self, query_stmt: str, as_dict: bool = False) -> list:\n        \"\"\"Executes query on `self.container` and returns results.\"\"\"\n        query = self.container.query(query_stmt)\n        row_set = query.fetch()\n\n        results = []\n        columns = row_set.get_column_names()\n\n        while row_set.has_next():\n            row = row_set.next()\n\n            if as_dict:\n                row = dict((k, v) for k, v in zip(columns, row))\n\n            results.append(row)\n\n        return results\n\n    def cleanup(self) -> None:\n        \"\"\"Closes container and store objects.\"\"\"\n        if self.container is not None:\n            self.container.close()\n\n        if self.gridstore is not None:\n            self.gridstore.close()<\/code><\/pre>\n<\/div>\n<p>\u3053\u306e\u30af\u30e9\u30b9\u304c\u30a2\u30d7\u30ea\u5168\u4f53\u3067\u3069\u306e\u3088\u3046\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u304b\u3001\u4ee5\u4e0b\u3067\u8aac\u660e\u3057\u307e\u3059\u3002\u306a\u304a\u3001handle_exception\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u306f\u3001<code>.\/app\/db\/utils.py<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>GridDB\u30b3\u30f3\u30c6\u30ca\u306e\u521d\u671f\u5316<\/h3>\n<p>\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u7528\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001\u30b3\u30f3\u30c6\u30ca\u306e\u5b9a\u7fa9\u3068\u521d\u671f\u5316\u3092\u884c\u3046\u30b9\u30bf\u30f3\u30c9\u30a2\u30ed\u30fc\u30f3\u306ePython\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\n#!\/usr\/bin\/python\nimport griddb_python as griddb\n\nfrom app.db.connection import GridDBConnection\nfrom app.config import GRIDDB_CONNECTION_PARAMS, GRIDDB_CONTAINER_NAME\n\ndef main() -> None:\n    try:\n        gdb = GridDBConnection(GRIDDB_CONNECTION_PARAMS)\n\n        print(\"Initializing GridDB connection\")\n        gdb.init()\n\n        print(f\"Creating container {GRIDDB_CONTAINER_NAME}\")\n        con_info = griddb.ContainerInfo(\n            name=GRIDDB_CONTAINER_NAME,\n            column_info_list=[\n                [\"timestamp\", griddb.Type.TIMESTAMP],\n                [\"temperature\", griddb.Type.DOUBLE],\n                [\"pressure\", griddb.Type.DOUBLE],\n                [\"humidity\", griddb.Type.DOUBLE],\n            ],\n            type=griddb.ContainerType.TIME_SERIES\n        )\n\n        gdb.create_container(con_info)\n\n        print('Done')\n    except Exception as e:\n        print(f\"Error initializing GridDB: {e}\")\n\nif __name__ == \"__main__\":\n    main()\n  <\/code><\/pre>\n<\/div>\n<p>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001uvicorn\u30b5\u30fc\u30d0\u3092\u8d77\u52d5\u3059\u308b\u524d\u306b\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4ee3\u308f\u308a\u306b\u3001bash\u30b9\u30af\u30ea\u30d7\u30c8 <code>.\/run.sh<\/code> \u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>GridDB \u63a5\u7d9a\u306e\u8a2d\u5b9a<\/h3>\n<p>\u30a2\u30d7\u30ea\u30b5\u30fc\u30d0\u306e\u8d77\u52d5\u6642\u306b GridDB \u30b5\u30fc\u30d0\u3078\u306e\u63a5\u7d9a\u3092\u78ba\u7acb\u3057\u3001\u30a2\u30d7\u30ea\u30b5\u30fc\u30d0\u306e\u505c\u6b62\u6642\u306b\u63a5\u7d9a\u3092\u7d42\u4e86\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u30a2\u30d7\u30ea\u5168\u4f53\u3067GridDBConnection\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3059\u305f\u3081\u306b\u3001<code>.\/app\/main.py<\/code>\u306e\u4e00\u90e8\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\nimport logging\nfrom typing import Optional\n\nfrom fastapi import FastAPI, Response, status\n\nfrom .config import (\n    GRIDDB_CONNECTION_PARAMS,\n    GRIDDB_CONTAINER_NAME,\n)\nfrom .db import GridDBConnection\nfrom .schema import ResponseModel\nfrom .services.weatherstation import get_sensor_data\n\nlogger = logging.getLogger(\"api\")\n\napp = FastAPI()\n\n@app.on_event(\"startup\")\nasync def startup_event():\n    logger.info(\"Server startup\")\n\n    logger.info(\"Initializing GridDB connection\")\n    gdb = GridDBConnection(GRIDDB_CONNECTION_PARAMS)\n    gdb.init(GRIDDB_CONTAINER_NAME)\n\n    app.state.griddb = gdb\n    logger.info(\"Server Startup\")\n\n@app.on_event(\"shutdown\")\nasync def shutdown_event():\n    app.state.griddb.cleanup()\n    logger.info(\"Server Shutdown\")\n\n# ... Continued on next code block ...\n  <\/code><\/pre>\n<\/div>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001GridDB\u30b5\u30fc\u30d0\u3078\u306e\u63a5\u7d9a\u3068\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u30b3\u30f3\u30c6\u30ca\u306e\u9078\u629e\u304c\u3001\u30a2\u30d7\u30ea\u30b5\u30fc\u30d0\u306e\u8d77\u52d5\u6642\u306b\u884c\u308f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u4f5c\u6210\u3055\u308c\u305fGridDBConnection\u306fapp.state.griddb\u5c5e\u6027\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u3001\u30a2\u30d7\u30ea\u5168\u4f53\u3067\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8<\/h3>\n<p>\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306f\u30012\u3064\u306eAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4ecb\u3057\u3066Web\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306f\u3001.\/app\/main.py\u30d5\u30a1\u30a4\u30eb\u306e\u6b21\u306e\u90e8\u5206\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\n# ... Continued from previous code block ...\n\n@app.post(\"\/record\", response_model=ResponseModel)\nasync def save_current_sensor_data(response: Response):\n    \"\"\"Gets data from sensors and stores it in GridDB.\"\"\"\n    sensor_data = get_sensor_data()\n    app.state.griddb.container.put(list(sensor_data.values()))\n\n    response.status_code = status.HTTP_201_CREATED\n    return {\n        \"status\": \"Successfully stored new reading\",\n        \"records\": 1,\n        \"data\": [sensor_data],\n    }\n\n@app.get(\"\/retrieve\", response_model=ResponseModel)\nasync def get_stored_readings(minutes: Optional[int] = 5):\n    \"\"\"Retrieves stored readings within given number of minutes ago.\"\"\"\n    stmt = f\"\"\"\n        select * \n        where timestamp > TIMESTAMPADD(MINUTE, NOW(), -{minutes})\n        order by timestamp desc\n    \"\"\"\n    data = app.state.griddb.execute_and_fetch(stmt, as_dict=True)\n\n    return {\n        \"status\": f\"Retrieved stored records within last {minutes} minutes\",\n        \"records\": len(data),\n        \"data\": data,\n    }\n  <\/code><\/pre>\n<\/div>\n<p>\u3053\u3053\u3067\u306f\u30012\u3064\u306eAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>POST \/record <\/li>\n<li>GET \/retrieve <\/li>\n<\/ul>\n<p><code>\/record<\/code> \u306f\u3001\u6c17\u8c61\u30bb\u30f3\u30b5\u30fc\u3092\u8d77\u52d5\u3057\u3001\u73fe\u5728\u306e\u8aad\u307f\u53d6\u308a\u5024\u3092 GridDB \u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002POST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u3001201 CREATED\u30ec\u30b9\u30dd\u30f3\u30b9\u3068\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30e1\u30c3\u30bb\u30fc\u30b8\u3001\u30ec\u30b3\u30fc\u30c9\u6570\u3001\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30ec\u30b3\u30fc\u30c9\u3092\u542b\u3080JSON\u30dc\u30c7\u30a3\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p><code>\/retrieve<\/code> \u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u6570\u5206\u524d\u4ee5\u5185\u306e\u6700\u65b0\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u30d5\u30a7\u30c3\u30c1\u3057\u307e\u3059\u3002GET\u30ea\u30af\u30a8\u30b9\u30c8\u3068\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf minutes \u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002\u305d\u3057\u3066\u3001200 OK\u30ec\u30b9\u30dd\u30f3\u30b9\u3068\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30e1\u30c3\u30bb\u30fc\u30b8\u3001\u30ec\u30b3\u30fc\u30c9\u6570\u3001\u53d6\u5f97\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u306e\u914d\u5217\u3092\u542b\u3080JSON\u30dc\u30c7\u30a3\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30ec\u30b9\u30dd\u30f3\u30b9\u30b9\u30ad\u30fc\u30de<\/h3>\n<p>FastAPI\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u7528\u3059\u308b\u4e3b\u306a\u5229\u70b9\u306f\u3001\u958b\u767a\u8005\u306e\u624b\u9593\u3092\u304b\u3051\u305a\u306b\u3001\u30a2\u30d7\u30ea\u304c\u6b63\u3057\u3044\u30c7\u30fc\u30bf\u30bf\u30a4\u30d7\u3068\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d7\u3051\u5165\u308c\u3066\u8fd4\u3059\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b\u3055\u307e\u3056\u307e\u306a\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u3088\u3046\u306a\u6a5f\u80fd\u306e1\u3064\u3068\u3057\u3066\u3001pydantic\u30e2\u30c7\u30eb\u3092\u4f7f\u7528\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u89e3\u6790\u3057\u3001\u691c\u8a3c\u3059\u308b\u3053\u3068\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002\u4e0a\u8a18\u306e2\u3064\u306eAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u5b9a\u7fa9\u3067\u306f\u3001\u95a2\u6570\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u306eresponse_model\u5f15\u6570\u306bResponseModel\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u304c\u3001\u30d5\u30a1\u30a4\u30eb <code>.\/app\/schema\/response.py<\/code> \u306e ResponseModel \u30af\u30e9\u30b9\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u30b9\u30ad\u30fc\u30de\u306b\u5f93\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-py\">\nfrom typing import List, Optional\n\nfrom pydantic import BaseModel\n\nclass ResponseModel(BaseModel):\n    status: str = \"ok\"\n    records: Optional[int] = 0\n    data: Optional[List[dict]] = []\n  <\/code><\/pre>\n<\/div>\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001API\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u306e\u4f7f\u7528\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5168\u4f53\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u307e\u305a\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u6b63\u3057\u304f\u63a5\u7d9a\u3055\u308c\u3001GridDB\u30b5\u30fc\u30d0\u304c\u3059\u3067\u306b\u7a3c\u50cd\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u3001\u30a6\u30a7\u30b6\u30fc\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u30b3\u30f3\u30c6\u30ca\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ python init_griddb.py<\/code><\/p>\n<p>\u305d\u306e\u5f8c\u306b\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ uvicorn app.main:app --host 0.0.0.0 --port 80<\/code><\/p>\n<p>\u307e\u305f\u3001.\/run.sh\u3068\u3044\u3046bash\u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3059\u308c\u3070\u3001\u4e0a\u8a18\u306e\u4e21\u65b9\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4e00\u5ea6\u306b\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001API\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306f\u3001127.0.01\uff08localhost\uff09\u306e80\u756a\u30dd\u30fc\u30c8\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001docker\u30b3\u30f3\u30c6\u30ca\u7d4c\u7531\u3067\u5b9f\u884c\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306flocalhost\u3067\u306f\u306a\u304f\u3001docker\u30b3\u30f3\u30c6\u30ca\u3084docker\u30de\u30b7\u30f3\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u4ecb\u3057\u3066\u884c\u308f\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u4ee5\u964d\u306e\u4f8b\u3067\u306f\u3001\u6b63\u3057\u3044IP\u30a2\u30c9\u30ec\u30b9\u3068\u30dd\u30fc\u30c8\u3092\u8a2d\u5b9a\u306b\u4ee3\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>curl\u3092\u4f7f\u3063\u3066API\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u307e\u305a\u3001\u30bb\u30f3\u30b5\u30fc\u3092\u8d77\u52d5\u3057\u3001\u73fe\u5728\u306e\u6c17\u8c61\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ curl -X POST http:\/\/IP_ADDRESS:PORT\/record<\/code><\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u3063\u3066\u304f\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre><code>{\"status\":\"Successfully stored new reading\",\"records\":1,\"data\":[{\"timestamp\":\"2021-02-17T10:18:06.509054\",\"temperature\":29.530784788460004,\"pressure\":1004.8003564430331,\"humidity\":64}]}\n<\/code><\/pre>\n<p>\u904e\u53bb5\u5206\u4ee5\u5185\u306e\u76f4\u8fd1\u306b\u4fdd\u5b58\u3055\u308c\u305f\u8aad\u307f\u53d6\u308a\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\uff08\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf minutes\u306b\u5024\u3092\u6e21\u3055\u306a\u3044\u5834\u5408\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306f5\u3067\u3059\uff09\u3002<\/p>\n<p><code>$ curl http:\/\/IP_ADDRESS:PORT\/retrieve<\/code><\/p>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre><code>{\"status\":\"Retrieved stored records within last 5 minutes\",\"records\":3,\"data\":[{\"timestamp\":\"2021-02-17T10:23:54.940000\",\"temperature\":29.649967592036077,\"pressure\":1005.0168541036603,\"humidity\":53.0},{\"timestamp\":\"2021-02-17T10:23:52.531000\",\"temperature\":29.767032247389704,\"pressure\":991.8437893041985,\"humidity\":73.0},{\"timestamp\":\"2021-02-17T10:23:46.351000\",\"temperature\":31.720923387508172,\"pressure\":1011.998375306113,\"humidity\":95.0}]}\n<\/code><\/pre>\n<p>\u904e\u53bb10\u5206\u4ee5\u5185\u306b\u4fdd\u5b58\u3055\u308c\u305f\u8aad\u307f\u53d6\u308a\u5024\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p><code>$ curl http:\/\/IP_ADDRESS:PORT\/retrieve?minutes=10<\/code><\/p>\n<p>\u3053\u306e\u5834\u5408\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<p><code>{\"status\":\"Retrieved stored records within last 10 minutes\",\"records\":7,\"data\":[{\"timestamp\":\"2021-02-17T10:23:54.940000\",\"temperature\":29.649967592036077,\"pressure\":1005.0168541036603,\"humidity\":53.0},{\"timestamp\":\"2021-02-17T10:23:52.531000\",\"temperature\":29.767032247389704,\"pressure\":991.8437893041985,\"humidity\":73.0},{\"timestamp\":\"2021-02-17T10:23:46.351000\",\"temperature\":31.720923387508172,\"pressure\":1011.998375306113,\"humidity\":95.0},{\"timestamp\":\"2021-02-17T10:18:34.288000\",\"temperature\":28.10441189566165,\"pressure\":1028.2311879177432,\"humidity\":67.0},{\"timestamp\":\"2021-02-17T10:18:30.304000\",\"temperature\":29.996273963137778,\"pressure\":1007.5716385639391,\"humidity\":52.0},{\"timestamp\":\"2021-02-17T10:18:22.655000\",\"temperature\":28.823514215164877,\"pressure\":989.7959636620639,\"humidity\":66.0},{\"timestamp\":\"2021-02-17T10:18:06.509000\",\"temperature\":29.530784788460004,\"pressure\":1004.8003564430331,\"humidity\":64.0}]}<\/code><\/p>\n<p>\u3053\u308c\u3067\u3001cron\u30b8\u30e7\u30d6\u3084Lambda Function\u3092\u8a2d\u5b9a\u3057\u3066\u3001<code>\/record<\/code> API\u3092\u5b9a\u671f\u7684\u306b\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u3084\u30c7\u30fc\u30bf\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30bc\u30fc\u30b7\u30e7\u30f3\u30a2\u30d7\u30ea\u3092\u7d71\u5408\u3057\u3066\u3001<code>\/retrieve<\/code> API\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u305d\u306e\u4ed6\u306e\u691c\u8a0e\u4e8b\u9805<\/h2>\n<p>\u4eca\u56de\u5b9f\u88c5\u3057\u305f\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u3055\u3089\u306b\u62e1\u5f35\u3057\u305f\u308a\u3001\u5225\u306e\u65b9\u5411\u306b\u6301\u3063\u3066\u3044\u304f\u305f\u3081\u306e\u30a2\u30a4\u30c7\u30a2\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30c7\u30fc\u30bf\u30af\u30ea\u30fc\u30cb\u30f3\u30b0\u3084\u30c7\u30fc\u30bf\u51e6\u7406\u306a\u3069\u306e\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u52a0\u3059\u308b\u3002\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u69cb\u9020\u3067\u306f\u3001\u65b0\u3057\u3044\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u3066\u3001\u65e2\u5b58\u307e\u305f\u306f\u8ffd\u52a0\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3068\u63a5\u7d9a\u3059\u308b\u3053\u3068\u304c\u975e\u5e38\u306b\u7c21\u5358\u3067\u3059\u3002<\/li>\n<li>MQTT\u30e1\u30c3\u30bb\u30fc\u30b8\u30d6\u30ed\u30fc\u30ab\u3092\u4f7f\u7528\u3057\u3066\u3001GridDB\u304c\u65b0\u3057\u3044\u30bb\u30f3\u30b5\u30c7\u30fc\u30bf\u3092\u76f4\u63a5\u30ea\u30c3\u30b9\u30f3\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002\u3053\u308c\u306f\u3001<a href=\"https:\/\/griddb.net\/ja\/blog\/monitoring-temperature-sensor-data-with-an-arduino-based-plc-mqtt-node-red-griddb-and-grafana\/\">\u5225\u306eGridDB\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059<\/a>\u3002<\/li>\n<li>HTTP\u3068MQTT\u306e\u4e21\u65b9\u306e\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<a href=\"https:\/\/pypi.org\/project\/fastapi-mqtt\/\">fastapi-mqtt<\/a>\u3068\u3044\u3046FastAPI\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308a\u3001\u3053\u308c\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u6c17\u8c61IoT\u5411\u3051\u306bFastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u30b7\u30f3\u30d7\u30eb\u304b\u3064\u62e1\u5f35\u53ef\u80fd\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u5b9f\u88c5\u3092\u69cb\u7bc9\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3089\u306e\u30c4\u30fc\u30eb\u306f\u3001\u7279\u306b\u591a\u304f\u306e\u7570\u306a\u308bIoT\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u306e\u30b7\u30fc\u30e0\u30ec\u30b9\u306a\u7d71\u5408\u3092\u5fc5\u8981\u3068\u3059\u308b\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u304a\u3044\u3066\u3001\u30c7\u30fc\u30bf\u96c6\u7d04\u578b\u306e\u30b7\u30b9\u30c6\u30e0\u3092\u7c21\u5358\u306b\u4f5c\u6210\u30fb\u7dad\u6301\u3059\u308b\u306e\u306b\u5f79\u7acb\u3064\u3053\u3068\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<\/p>\n<h2 id=\"source-code\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<p><a href=\"https:\/\/github.com\/griddbnet\/Blogs\/tree\/main\/Build%20a%20Data%20Pipeline%20for%20Weather%20IoT%20with%20FastAPI%20and%20GridDB\"> GitHub <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u3053\u306e\u8a18\u4e8b\u3092\u8aad\u307f\u7d42\u3048\u308b\u9803\u306b\u306f\u3001\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7 [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":49212,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1005],"tags":[],"class_list":["post-50748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1005"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39\" \/>\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\/ja\/\u672a\u5206\u985e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/ja\/\u672a\u5206\u985e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\" \/>\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=\"2021-03-12T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-14T15:54:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1707\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\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=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"5\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9\",\"datePublished\":\"2021-03-12T08:00:00+00:00\",\"dateModified\":\"2025-11-14T15:54:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\"},\"wordCount\":164,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg\",\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\",\"url\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\",\"name\":\"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg\",\"datePublished\":\"2021-03-12T08:00:00+00:00\",\"dateModified\":\"2025-11-14T15:54:42+00:00\",\"description\":\"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39\",\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg\",\"contentUrl\":\"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg\",\"width\":2560,\"height\":1707},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.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.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/griddb.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.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.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/www.griddb.net\/ja\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT","description":"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39","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\/ja\/\u672a\u5206\u985e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/","og_locale":"ja_JP","og_type":"article","og_title":"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT","og_description":"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39","og_url":"https:\/\/griddb.net\/ja\/\u672a\u5206\u985e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2021-03-12T08:00:00+00:00","article_modified_time":"2025-11-14T15:54:42+00:00","og_image":[{"width":2560,"height":1707,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"\u57f7\u7b46\u8005":"griddb-admin","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"5\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9","datePublished":"2021-03-12T08:00:00+00:00","dateModified":"2025-11-14T15:54:42+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/"},"wordCount":164,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg","inLanguage":"ja","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/","url":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/","name":"FastAPI\u3068GridDB\u306b\u3088\u308b\u6c17\u8c61IoT\u306e\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u69cb\u7bc9 | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg","datePublished":"2021-03-12T08:00:00+00:00","dateModified":"2025-11-14T15:54:42+00:00","description":"\u672c\u65e5\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u306f\u3001FastAPI\u3068GridDB\u3092\u4f7f\u7528\u3057\u3066\u3001\u6c17\u8c61IoT\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u305f\u3081\u306e\u5805\u7262\u306a\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3001\u5b9f\u8df5\u7684\u306a\u30ac\u30a4\u30c9\u3092\u3054\u7d39","inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/build-a-data-pipeline-for-weather-iot-with-fastapi-and-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg","contentUrl":"\/wp-content\/uploads\/2021\/03\/44429-sunset_2560x1707.jpg","width":2560,"height":1707},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.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.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/griddb.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.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.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/www.griddb.net\/ja\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/comments?post=50748"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50748\/revisions"}],"predecessor-version":[{"id":51585,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50748\/revisions\/51585"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/media\/49212"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/media?parent=50748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/categories?post=50748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/ja\/wp-json\/wp\/v2\/tags?post=50748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}