정보
Django
Python 3.12.4
Django 에서 influxdb_client 모듈을 사용 해 data 조회
조회 함수를 만들고, 조회 과정에서 에러가 생겼다.
{
"status": "error",
"code": "INVALID_INPUT",
"message": "(400)\nReason: Bad Request\nHTTP response headers: HTTPHeaderDict({
'Content-Type': 'application/json; charset=utf-8',
'Vary': 'Accept-Encoding',
'X-Influxdb-Build': 'OSS',
'X-Influxdb-Version': 'v2.7.6',
'X-Platform-Error-Code': 'invalid',
'Date': 'Tue, 03 Sep 2024 05:57:20 GMT',
'Transfer-Encoding': 'chunked'
})\n
HTTP response body: b'{
\"code\":\"invalid\",
\"message\":\"compilation failed: error @3:10-3:75: expected comma in property list, got COLON\\\\n\\\\n
error @3:10-3:75: expected comma in property list, got COLON\\\\n\\\\n
error @3:24-3:34: invalid expression @3:23-3:24: \\'\\\\n\\\\n
error @3:35-3:37: invalid integer literal \\\\\"00\\\\\": nonzero value cannot start with 0\\\\n\\\\nerror @3:37-3:40: missing property key\\\\n\\\\nerror @3:38-3:40: invalid integer literal \\\\\"00\\\\\": nonzero value cannot start with 0\\\\n\\\\nerror @3:40-3:44: invalid expression @3:43-3:44: \\'\\\\n\\\\nerror @3:40-3:44: missing property key\\\\n\\\\nerror @3:41-3:43: invalid integer literal \\\\\"00\\\\\": nonzero value cannot start with 0\\\\n\\\\nerror @3:46-3:73: invalid expression @3:73-3:74: \\'\\\\n\\\\n
error @3:53-3:73: invalid expression @3:52-3:53: \\'\"
}'\n"
에러는 postman 으로 테스트 중 flux query 에서 start, end time 의 형식이 맞지 않아 생긴거였다.
원인과 해결
influxDB 에서는 timestamp 를 2024-07-26T00:00:00Z 와 같은 RFC3339 형식을 사용해야 한다.
그러나 나는 influxdb GUI 에 접속하여 timestamp 를 보고 위 사진과 같이 되어있길래 2024-07-26 00:00:00 라고 값을 넣어서 생긴 문제였다.
항상 기본적인걸 잘 지키려고 노력하자
'Python' 카테고리의 다른 글
Python) PyCham 에서 Django 서버 기본 설정 (0) | 2024.06.10 |
---|