influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
724 stars 187 forks source link

Exception while sending data. #573

Closed Syman123 closed 1 year ago

Syman123 commented 1 year ago

Hello, I got an exception while sending the data and sending successful. But it excepts. i think it mostly is the official python example i use. Any ideas why this fails? Float to int conversion? At the beginning of the code snipping is the data which is sended. Thanks bye

user@raspberrypi:~ $ sudo python3 deconz_aqara_multisensor.py

[{'time': datetime.datetime(2023, 5, 8, 19, 9, 47, 182124, tzinfo=<DstTzInfo 'Europe/Vienna' CEST+2:00:00 DST>), 'measurement': 'Multisensor', 'tags': {'sensor': 'humidity'}, 'fields': {'value': 84.14}}] [{'time': datetime.datetime(2023, 5, 8, 19, 9, 47, 182124, tzinfo=<DstTzInfo 'Europe/Vienna' CEST+2:00:00 DST>), 'measurement': 'Multisensor', 'tags': {'sensor': 'temperature'}, 'fields': {'value': 18.38}}] [{'time': datetime.datetime(2023, 5, 8, 19, 9, 47, 182124, tzinfo=<DstTzInfo 'Europe/Vienna' CEST+2:00:00 DST>), 'measurement': 'Multisensor', 'tags': {'sensor': 'pressure'}, 'fields': {'value': 966}}] Traceback (most recent call last): File "/home/simon/deconz_aqara_multisensor.py", line 134, in getEnvSensorValues() File "/home/simon/deconz_aqara_multisensor.py", line 130, in getEnvSensorValues write_api.write(bucket=bucket, org=org, record=point) File "/usr/local/lib/python3.9/dist-packages/influxdb_client/client/write_api.py", line 378, in write results = list(map(write_payload, payloads.items())) File "/usr/local/lib/python3.9/dist-packages/influxdb_client/client/write_api.py", line 376, in write_payload return self._post_write(_async_req, bucket, org, final_string, payload[0]) File "/usr/local/lib/python3.9/dist-packages/influxdb_client/client/write_api.py", line 509, in _post_write return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision, File "/usr/local/lib/python3.9/dist-packages/influxdb_client/service/write_service.py", line 60, in post_write (data) = self.post_write_with_http_info(org, bucket, body, **kwargs) # noqa: E501 File "/usr/local/lib/python3.9/dist-packages/influxdb_client/service/write_service.py", line 90, in post_write_with_http_info return self.api_client.call_api( File "/usr/local/lib/python3.9/dist-packages/influxdb_client/_sync/api_client.py", line 343, in call_api return self.__call_api(resource_path, method, File "/usr/local/lib/python3.9/dist-packages/influxdb_client/_sync/api_client.py", line 173, in __call_api response_data = self.request( File "/usr/local/lib/python3.9/dist-packages/influxdb_client/_sync/api_client.py", line 388, in request return self.rest_client.POST(url, File "/usr/local/lib/python3.9/dist-packages/influxdb_client/_sync/rest.py", line 311, in POST return self.request("POST", url, File "/usr/local/lib/python3.9/dist-packages/influxdb_client/_sync/rest.py", line 261, in request raise ApiException(http_resp=r) influxdb_client.rest.ApiException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Date': 'Mon, 08 May 2023 17:09:50 GMT', 'Content-Type': 'application/json', 'Content-Length': '133', 'Connection': 'keep-alive', 'trace-id': 'fe3103259695da2e', 'trace-sampled': 'false', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains', 'X-Influxdb-Request-ID': '1d833e1eab749109f4a28c36fdde6935', 'X-Influxdb-Build': 'Cloud'}) HTTP response body: {"code":"invalid","message":"dml handler error: schema conflict: table Multisensor, column value is type f64 but write has type i64"}

powersj commented 1 year ago

The response body contains the reason for the issue:

HTTP response body: {"code":"invalid","message":"dml handler error: schema conflict: table Multisensor, column value is type f64 but write has type i64"}

It means that the column was originally written with float 64 data type and now you are trying to write it with an int 64. Once data for a column is created it needs to stay of the same data type.