# Ingesting Data via Python to Elastic

**URL:** <https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230>\
**Category:** Elasticsearch\
**Created:** [September 2, 2020, 12:28pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230 "2020-09-02T12:28:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul0711](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rahul0711](https://discuss.elastic.co/u/Rahul0711)\
**Post date:** [September 2, 2020, 12:28pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/1 "2020-09-02T12:28:51Z")

</div>

Hello Team  
I need help in ingesting the data via python into elastic. I have a cert that I have already uploaded the cert on the browser. After pre-processing is completed, I converted dataframe into dict. Now I want to ingest this into elastic. Need help on the syntax. Usually when cert is not there you ingest directly by entering IP and the auth. Need help when we have cert.  
How to edit the below syntax when we have cert and what library to be used apart from elasticsearch

documents = df.to\_dict(orient='records')

es = Elasticsearch(hosts=['I have the HOST'],timeout=600, http\_auth=('USERID', 'PWD') )

bulk(es, documents, index='index\_name',doc\_type='doc', raise\_on\_error=False, ignore=400)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 2, 2020, 10:20pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/2 "2020-09-02T22:20:50Z")

</div>

Are you asking how to make the client use HTTPS when connecting to Elasticsearch?

---

<div class="post-metadata">

**Author:** ![Rahul0711](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rahul0711](https://discuss.elastic.co/u/Rahul0711)\
**Post date:** [September 3, 2020, 3:25pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/3 "2020-09-03T15:25:14Z")

</div>

Hello Mark  
Yes..Using https...  
I used the below code after converting the dataframe in dict

context = create\_default\_context(capath="Path of the .crt file")  
context.check\_hostname = False  
context.verify\_mode = ssl.CERT\_NONE

es = Elasticsearch(  
['HOST'],  
http\_auth=('USEDID', 'PASSWORD'),  
scheme="https",  
port=443,  
ssl\_context=context  
)

But still getting the error  
ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPSConnectionPool(host=HOSTNAME', port=443): Read timed out. (read timeout=10))

Elastic Instance is up

---

<div class="post-metadata">

**Author:** ![Rahul0711](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rahul0711](https://discuss.elastic.co/u/Rahul0711)\
**Post date:** [September 3, 2020, 3:31pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/4 "2020-09-03T15:31:11Z")

</div>

Used the below Link  
[https://elasticsearch-py.readthedocs.io/en/master/](https://elasticsearch-py.readthedocs.io/en/master/)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 3, 2020, 9:20pm UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/5 "2020-09-03T21:20:44Z")

</div>

You can do a HTTPS curl against the Elasticsearch instance successfully?

---

<div class="post-metadata">

**Author:** ![Rahul0711](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Rahul0711](https://discuss.elastic.co/u/Rahul0711)\
**Post date:** [September 4, 2020, 8:52am UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/6 "2020-09-04T08:52:14Z")

</div>

Yes..its sucessful

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 2, 2020, 8:52am UTC](https://discuss.elastic.co/t/ingesting-data-via-python-to-elastic/247230/7 "2020-10-02T08:52:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
