Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple script to import JSONL into PostgreSQL
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