{"componentChunkName":"component---src-templates-simple-markdown-js","path":"/data-ingestion-api/python-example/","matchPath":"","result":{"data":{"markdownRemark":{"html":"<h1 style=\"position:relative;\"><a href=\"#python-example\" aria-label=\"python example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"python-example\"></div>Python Example</h1>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"81215376762361360000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`# Test script for data job push API. \n# Uploads a given parquet file. \n#\n# Parameter:\n# - Parquet filename in the current directory\n#\n#\n# Before usage:\n# Update app_key or api_key, pool_id, targetName and eventually base_url to your needs.\n#\n\n\nimport datetime\nimport sys\nimport uuid\n\nimport requests\n\n# Adopt to your needs\napp_key = &quot;YOUR APP KEY&quot; # You can create this under the team setting page and application key\napi_key = &quot;YOUR API KEY&quot; # You can create this under user setting by going to edit profile and api keys section\npool_id = &quot;YOUR POOL ID&quot;\ntargetName = &quot;TABLE_PARQUET&quot;\n\n\nbase_url = &quot;YOUR TEAM CELONIS DOMAIN&quot; \nconnection_id =&quot;YOUR CONNECTION ID&quot; # this is optional you can also push on data pool global schema\n\nclient_id = str(uuid.uuid4())\nfile_name = sys.argv[1]\n\nurl = base_url + &quot;/integration/api/v1/data-push/&quot; + pool_id + &quot;/jobs/&quot;\n\nprint('file_name', file_name)\n\n\nbody={'type': 'DELTA', 'fileType': 'PARQUET', 'targetName': targetName, 'dataPoolId': pool_id}\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'application/json'} \n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'} \nresponse = requests.post(url=url ,json=body, headers=headers)\nif response.status_code != 200:\n    print(&quot;Received non 200 code created data push job&quot;, response.status_code)\n   \ndata_push_job = response.json()\nprint(str(datetime.datetime.now()) + &quot;: Data push job &quot; +response.text + &quot; successful created &quot;)\n\n\n\npush_chunk_url = url + data_push_job['id'] + &quot;/chunks/upserted&quot;\nprint(push_chunk_url);\nfile = {'file': open(file_name, 'rb')}\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'multipart/form-data'}\n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'}\nresponse = requests.post(url=push_chunk_url ,files=file, headers=headers)\n\nif response.status_code != 200:\n    print(&quot;Received non 200 code on pushing chunk&quot;, response.status_code)\n   \n\nprint(str(datetime.datetime.now()) + &quot;: Data push job chunk&quot; + response.text + &quot; successful created &quot;)\n\n\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'application/json'}\n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'}\nurl =url+data_push_job['id']\nresponse = requests.post(url=url ,json={}, headers=headers)\nif response.status_code != 200:\n    print(&quot;Received non 200 code created data push job&quot;, response.status_code)\n\nprint(str(datetime.datetime.now()) + &quot;: Successful data push job &quot;, response.text)\n\n#data_push_job {'file': open(file_name, 'rb')}`, `81215376762361360000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-81215376762361360000\">Copied</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Test script for data job push API. \n# Uploads a given parquet file. \n#\n# Parameter:\n# - Parquet filename in the current directory\n#\n#\n# Before usage:\n# Update app_key or api_key, pool_id, targetName and eventually base_url to your needs.\n#\n\n\nimport datetime\nimport sys\nimport uuid\n\nimport requests\n\n# Adopt to your needs\napp_key = \"YOUR APP KEY\" # You can create this under the team setting page and application key\napi_key = \"YOUR API KEY\" # You can create this under user setting by going to edit profile and api keys section\npool_id = \"YOUR POOL ID\"\ntargetName = \"TABLE_PARQUET\"\n\n\nbase_url = \"YOUR TEAM CELONIS DOMAIN\" \nconnection_id =\"YOUR CONNECTION ID\" # this is optional you can also push on data pool global schema\n\nclient_id = str(uuid.uuid4())\nfile_name = sys.argv[1]\n\nurl = base_url + \"/integration/api/v1/data-push/\" + pool_id + \"/jobs/\"\n\nprint('file_name', file_name)\n\n\nbody={'type': 'DELTA', 'fileType': 'PARQUET', 'targetName': targetName, 'dataPoolId': pool_id}\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'application/json'} \n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'} \nresponse = requests.post(url=url ,json=body, headers=headers)\nif response.status_code != 200:\n    print(\"Received non 200 code created data push job\", response.status_code)\n   \ndata_push_job = response.json()\nprint(str(datetime.datetime.now()) + \": Data push job \" +response.text + \" successful created \")\n\n\n\npush_chunk_url = url + data_push_job['id'] + \"/chunks/upserted\"\nprint(push_chunk_url);\nfile = {'file': open(file_name, 'rb')}\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'multipart/form-data'}\n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'}\nresponse = requests.post(url=push_chunk_url ,files=file, headers=headers)\n\nif response.status_code != 200:\n    print(\"Received non 200 code on pushing chunk\", response.status_code)\n   \n\nprint(str(datetime.datetime.now()) + \": Data push job chunk\" + response.text + \" successful created \")\n\n\n# This is for authenticating with team based App Key\nheaders = {'Authorization': 'AppKey ' + app_key, 'Body-Type': 'application/json'}\n# Uncomment the line below if user based apiKey is used.\n# headers = {'Authorization': 'Bearer ' + api_key, 'Body-Type': 'application/json'}\nurl =url+data_push_job['id']\nresponse = requests.post(url=url ,json={}, headers=headers)\nif response.status_code != 200:\n    print(\"Received non 200 code created data push job\", response.status_code)\n\nprint(str(datetime.datetime.now()) + \": Successful data push job \", response.text)\n\n#data_push_job {'file': open(file_name, 'rb')}</code></pre></div>\n      </div>","headings":[{"value":"Python Example","depth":1}]},"contentItem":{"data":{"lastModified":"2024-01-02T12:48:17.000Z","enableToc":null,"disableLastModified":null,"tocMaxDepth":null,"requestLogin":false}},"siteConfig":{"enableToc":false,"disableLastModified":false,"tocMaxDepth":4}},"pageContext":{"matchPath":"","id":"91a9049f-f7a3-5ef2-a141-a27dd881ae2c__redocly content/data-ingestion-api/python-example/","seo":{"title":"Python Example","description":null,"image":"","keywords":null,"jsonLd":null,"lang":null,"siteUrl":null},"pageId":"data-ingestion-api/python-example.md","pageBaseUrl":"/data-ingestion-api/python-example","type":"markdown","toc":{"enable":true,"maxDepth":4,"headings":[{"depth":1,"value":"Python Example","id":"python-example"}]},"data":{"title":""},"catalogInfo":null,"link":"/data-ingestion-api/python-example/","sidebarName":"celonis","isLanding":false,"showPrevButton":null,"showNextButton":null,"apiVersions":null,"apiVersionId":null,"isDefaultApiVersion":null}},"staticQueryHashes":["1123603147","1302185487","1344209882","1398840060","1520077861","1975142765","2667623876","2950305614","3240152602","3743992808","561138138"]}