Skip to content

Instantly share code, notes, and snippets.

@tonkatsu7
Created November 1, 2020 06:22
Show Gist options
  • Save tonkatsu7/de9e09501a26cc4d0877ff95c0be3025 to your computer and use it in GitHub Desktop.
Save tonkatsu7/de9e09501a26cc4d0877ff95c0be3025 to your computer and use it in GitHub Desktop.
Connect to elasticsearch 7 using basic authentication in Python
host = 'SOME_GUID.southeastasia.azure.elastic-cloud.com' #without 'https'
basicAuth = ('USERNAME', 'PASSWORD')
es = elasticsearch.Elasticsearch(
hosts=[{'host': host, 'port': 9243}],
http_auth=basicAuth,
use_ssl=True,
verify_certs=True,
connection_class=elasticsearch.RequestsHttpConnection
)
print(es.info())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment