Skip to content

Instantly share code, notes, and snippets.

@bsnacks000
Created February 24, 2024 10:37
Show Gist options
  • Select an option

  • Save bsnacks000/8946ccd2ad56764686ef7eb4b43628ac to your computer and use it in GitHub Desktop.

Select an option

Save bsnacks000/8946ccd2ad56764686ef7eb4b43628ac to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simple pattern for exporting a query from postgres into jsonl using psql \copy command
pg_url=$POSTGRES_URL
fpath=$FPATH
psql $pg_url > $fpath << EOF
\copy(select to_jsonb(r) as jl from (select * from my_table) r ) to stdout;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment