A simple script to import JSONL into PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psql -d mydb -c "create table log ( id serial primary key, data jsonb not null);" | |
# escape the slashes and pipe it in (otherwise Postgres will drop drop slashes intended to escape quotation marks, etc) | |
sed 's/\\/\\\\/g' log.jsonl | psql -d mydb -c "copy log ( data ) FROM STDIN;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment