๐Ÿ Python

๐Ÿ Python

[Python] influxdb ์‚ฝ์ž… ์‹œ timezone ์ฃผ์˜์‚ฌํ•ญ (feat. datetime.now()๋ฅผ ์ง€์–‘ํ•˜์ž)

Intro ํŒŒ์ด์ฌ์œผ๋กœ InfluxDB์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ์‹œํ‚ค๋Š” ๋ชจ๋“ˆ์„ ๊ฐœ๋ฐœํ•˜๋‹ค ์ด์ƒํ•œ์ ์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค. KST๋กœ ๋„ฃ์—ˆ๋Š”๋ฐ ์ด๊ฒŒ ๊ทธ๋Œ€๋กœ UTC๋กœ ๋“ค์–ด๊ฐ€ ์žˆ๊ฑฐ๋‚˜ ๋ถ„๋ช… UTC๋กœ ์ €์žฅ์‹œ์ผฐ๋Š”๋ฐ KST๋กœ ์ €์žฅ๋˜์–ด์žˆ๊ฑฐ๋‚˜.. ํฌํ•œํ•œ ํ˜„์ƒ์ด ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ํŒŒ์ด์ฌ ์ฝ”๋“œ๋ฅผ ์ „๋ถ€ ๊นŒ๋ณด๋ฉฐ influxDB ์ €์žฅํ•  ๋•Œ ์‹œ๊ฐ„์„ ๋ณ€ํ™˜ํ•˜๋Š”์ง€์™€ ์„œ๋ฒ„ ํƒ€์ž„์กด๊ณผ ๊ด€๋ จ์ด ์žˆ๋Š”์ง€ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์„œ๋ฒ„์˜ ํƒ€์ž„์กด์ด ๋‹ค๋ฅด๋ฉด, influxdb์—๋Š” ์‹œ๊ฐ„์ด ์–ด๋–ป๊ฒŒ ์ฐํž๊นŒ? TL;DR ๐Ÿ’ก ์„œ๋ฒ„ ์‹œ๊ฐ„์— ๋”ฐ๋ผ์„œ `datetime.timestamp()` ํ•จ์ˆ˜๊ฐ€ UTC ์‹œ๊ฐ„์œผ๋กœ ๋ณด์ •ํ•˜์—ฌ ๋ณ€ํ™˜ํ•œ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์„œ๋ฒ„ ํƒ€์ž„์กด์— ๋”ฐ๋ผ์„œ timestamp()์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋‹ฌ๋ผ์งˆ ๋ฟ, influxdb_client ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ ์‚ฝ์ž… ์‹œ์—๋Š” ๋”ฐ๋กœ ์‹œ๊ฐ„์ด ๋ณ€..

iseunghan
'๐Ÿ Python' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก