본문 바로가기

IT Tools/Database

[InfluxDB] InfluxDB 에 저장된 테이블 CSV 파일로 추출하기

influx --precision rfc3339 -database '[database 이름]' -execute 'select * from "[measurement 이름]"' -format csv > [저장할 파일 위치 및 원하는 파일 이름].csv

'--precision rfc3339' 는 선택 사항

예시)

$ sudo influx --precision rfc3339 -database 'test' -execute 'select * from "table1"' -format csv > result.csv

 

테이블 추출에 조건을 달고 싶은 경우

  • 현재 시간 보다 2일 7시간 전까지의 데이터만 추출하고 싶은 경우

    $ influx --precision rfc3339 -database 'test' -execute 'select * from "table1" where time < now()-2d7h' -format csv > result.csv
  • timestamp 형식으로 일정 시간보다 작은 경우를 추출하고 싶은 경우

    $ influx --precision rfc3339 -database 'test' -execute 'select * from table1 where time <= 1595722232744636345' -format csv > result.csv
  • table 안에서 일정 column(열, feature, 값) 들만 뽑아내고 싶은 경우

    $ influx --precision rfc3339 -database 'test' -execute 'select time,name,age from table1 where time > "2020-07-27T02:43:07"' -format csv > result.csv
  • 일정 값에 조건을 주고 싶은 경우

    $ influx --precision rfc3339 -database 'test' -execute 'select time,name,age from table1 where "age" > 15' -format csv > result_20200727.csv

 

반응형