# Pushing of data into elastic search dashboard using Python

**URL:** <https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214>\
**Category:** Elasticsearch\
**Created:** [December 1, 2022, 7:00am UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214 "2022-12-01T07:00:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashank02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank02/32/99866_2.png) [@Shashank02](https://discuss.elastic.co/u/Shashank02)\
**Post date:** [December 1, 2022, 7:00am UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/1 "2022-12-01T07:00:57Z")

</div>

I am working on a project which collects twitter data. So, up until now, what I did is I collected some tweets and then stored them in a CSV format and uploaded it to the elastic cloud. I am now working on automatically pushing the data into the elastic cloud. But, I am not getting any results. Can anyone help me with this? Here is the code I've written for pushing the data:

 ![Screenshot (630)](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fbf99c7ceb2b2c902150a78a76e016dd5287f197.png)  
Can someone help me if there should be any changes made in the code? The error that I'm getting is : "ValueError: Can't specify the options 'http\_auth' via a dictionary in 'hosts', only 'host', 'path\_prefix', 'port', 'scheme', 'url\_prefix', 'use\_ssl' options are allowed"

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [December 1, 2022, 3:01pm UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/2 "2022-12-01T15:01:16Z")

</div>

Hi Shashank,

For next time, please try to include a formatted code text snippet rather than screenshot to show your code to make reading easier. Can you share which version of the client and which version of Elasticsearch you're using?

I'll try to help assuming you're using the latest version of the API. From the client docs of the [latest API](https://elasticsearch-py.readthedocs.io/en/v8.5.2/api.html#module-elasticsearch) , although I'm no Python expert, I think you need something like this where the options are individual method parameters rather than being included in the array the way you have above:

`es_client = Elasticsearch(“my-elasticsearch-host:port”, http_auth=(user,password))`

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Shashank02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank02/32/99866_2.png) [@Shashank02](https://discuss.elastic.co/u/Shashank02)\
**Post date:** [December 1, 2022, 5:50pm UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/3 "2022-12-01T17:50:29Z")

</div>

It is showing this error: "ValueError: Could not parse URL". I put out my Cloud deployment details which I got from the elastic Cloud, so why is it showing this error? The version of Elastic Search is '8.4.1' and the code is : ```  
es\_client = Elasticsearch()  
def doc\_generator(df):  
df\_iter = df.iterrows()  
for index, document in df\_iter:  
yield {  
"\_index": 'a1.index',  
"\_type": "\_doc",  
"\_id" : f"{document['id']}",  
"\_source": self.filterKeys(document),  
}  
helpers.bulk(es\_client, doc\_generator(df))

`I hope I can get some help regarding this because the previous method is not working

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [December 1, 2022, 6:05pm UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/4 "2022-12-01T18:05:49Z")

</div>

Shashank,  
I have no experience with cloud connection. but here is what you do

importing some library  
from elasticsearch import Elasticsearch, helpers

open connection with elasticsearch  
es = Elasticsearch('your hostname', http\_auth=('username', 'password'), port=9200 ) --\> this might be different on elastic version 8.x. works in 7.x  
print (es.info()) --\> if this does not work then you do not have proper connection to elastic.

create a data in to list of dictionary ,  
output\_data =[{ dictionary of fist record}, { dictionary of second record}]

now push that to elastic using bulk method  
pb = helpers.bulk(es, output\_data)  
print (pb)

---

<div class="post-metadata">

**Author:** ![Shashank02](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shashank02/32/99866_2.png) [@Shashank02](https://discuss.elastic.co/u/Shashank02)\
**Post date:** [December 2, 2022, 4:54am UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/5 "2022-12-02T04:54:50Z")

</div>

OK thanks for that, so mine is elastic version 8.x. So, I think that's why I am getting the problem. Can you help me with the current Elastic version then?

---

<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:** [December 30, 2022, 4:55am UTC](https://discuss.elastic.co/t/pushing-of-data-into-elastic-search-dashboard-using-python/320214/6 "2022-12-30T04:55:14Z")

</div>

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