influxdb-python
influxdb-python copied to clipboard
Using InfluxDBClient object in context manager
I recently started using influxdb and I am struggeling to use a InfluxDBClient() object as a context manager as mentioned in the documentation (https://influxdb-python.readthedocs.io/en/latest/api-documentation.html#influxdbclient). As a minimal working example I tried
with InfluxDBClient() as client:
print(client)
which returned None.
This behaviour can most likely be explained by the lack of the InfluxDBClient.__enter__() function in the version 5.3.1 I got from pip. Is there a reason why this addition of this function is not (yet) reflected in the pip version? If not, is it safe to install the version that is currently on the master branch?
Very kind regards and many thanks for the development of this amazing package!
- InfluxDB version: 1.8.10
- InfluxDB-python version: 5.3.1
- Python version: 3.8.10
- Operating system version: Ubuntu 20.04
It looks like the 5.3.1 tag has gone missing. Unsure why or how. However, if you look at the latest code in the master branch you will see that there is now an __enter__ and an __exit__. Hopefully soon the authors can create a 5.3.2 tag which includes that. https://github.com/influxdata/influxdb-python/blob/7cb565698c88bfbf9f4804650231bd28d09e2e6d/influxdb/client.py#L188