{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from memair import Memair\n", "# Use Otto the sandbox user's access token or create your own at https://memair.com/temporary_access_token\n", "access_token = '0000000000000000000000000000000000000000000000000000000000000000'\n", "\n", "user = Memair(access_token)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': {'Create': {'id': '46595', 'records_total': 4}}}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a Bulk Create can accept up to 50,000 records per request. They are processed in the background\n", "response = user.query('''\n", "mutation {\n", " Create(\n", " biometrics: [\n", " {type: systolic_pressure, value: 80},\n", " {type: diastolic_pressure, value: 120},\n", " {type: weight, value: 80}\n", " ]\n", " locations: [\n", " {lat: 42, lon: 42}\n", " ]\n", " )\n", " {\n", " id\n", " records_total\n", " }\n", "}\n", "''')\n", "\n", "bulk_id = response['data']['Create']['id']\n", "response" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': {'CreateStatus': {'records_processed': 4,\n", " 'records_total': 4,\n", " 'has_finished': True,\n", " 'finished_at': '2019-05-28T17:02:04Z'}}}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# You can monitor the progress of your Bulk Create using the Bulk Create Status endpoint\n", "response = user.query('''\n", " query {\n", " CreateStatus(\n", " id: %s\n", " )\n", " {\n", " records_processed\n", " records_total\n", " has_finished\n", " finished_at\n", " }\n", " }\n", "''' % (bulk_id))\n", "\n", "response" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }