Closed integraciones-tiagora closed 6 months ago
Hi @integraciones-tiagora,
¿ Do I need to upgrade my client? ¿Or is there any other available way to check the health of my connection?
You have to use the v2
client: https://github.com/influxdata/influxdb-client-python#pip-install. You are currently using the v1 client.
Regards
Thanks! I will try it and let you know.
Best regards, Rogelio
Specifications
Dear sirs: I am running my Python script on PyCharm 2022.3.3 (Community Edition). My call to InfluxDB works OK, but I would like to add some checks to my program in case the connection fails.
I found that I should use the following sentences:
health = client.health() if health.status == "pass": print("Connection OK") else: print(f"Connection error: {health.message}!")
But my interpreter fails with the following error message:
health = client.health() AttributeError: 'InfluxDBClient' object has no attribute 'health'
¿ Do I need to upgrade my client? ¿Or is there any other available way to check the health of my connection?
Your help will be greatly appreciated Best regards Rogelio
Code sample to reproduce problem
client = InfluxDBClient(host='10.235.2.19', port=8086, username='admin', password='nimda') client.switch_database('telegraf')
health = client.health() if health.status == "pass": print("Conexión exitosa a InfluxDB.") else: print(f"Error de conexión a InfluxDB: {health.message}!")
Expected behavior
I expect client.health() to return a pass or the error code
Actual behavior
My program fails with the following error message:
health = client.health() AttributeError: 'InfluxDBClient' object has no attribute 'health'
Additional info
No response