Json to sqlite3 import howto
Intro jsonํ์ผ์ sqlite3์ importํ๋ ๋ฐฉ๋ฒ json -> csv -> sqlite3 ์์๋ก ์งํํ๋ค. jq, sqlite3๊ฐ ์ฌ์ ์ ์ค์น๋์ด ์์ด์ผ ํ๋ค. jq๋ ๊ฒฝ๋ ๋ช ๋ น๋ผ์ธ json ๊ด๋ฆฌ ํ๋ก๊ทธ๋จ์ด๋ค. Requirement $ sudo apt install sqlite3 $ sudo apt install jq Getting the CSV $ cat data.json {"uri":"/","user_agent":"example1"} {"uri":"/foobar","user_agent":"example1"} {"uri":"/","user_agent":"example2"} {"uri":"/foobar","user_agent":"example3"} $ head -1 data.json | jq -r 'keys | @csv' "uri","user_agent" $ jq -r 'map(tostring) | @csv' < data.json "/","example1" "/foobar","example1" "/","example2" "/foobar","example3" $ % (head -1 data.json | jq -r 'keys | @csv' && jq -r 'map(tostring) | @csv' < data.json) > data.csv Loading it into sqlite3 $ sqlite3 somedata.db sqlite> .mode csv sqlite> .import data.csv my_table sqlite> select * from my_table where ... Links https://stackoverflow.com/questions/46407770/how-to-convert-a-json-file-to-an-sqlite-database ...