Skip to content

Instantly share code, notes, and snippets.

@JeffCarpenter
Last active February 23, 2023 04:05
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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