Skip to main content

Command Palette

Search for a command to run...

psqlでsupabaseに繋がる

Updated
1 min read

supabaseは便利です。

しかし、oldtypeである私は、ブラウザ上だけで操作が完結することに満足できません。

psqlで tableをCSVにdumpしてみる一例です。

URIに秘匿したいsupabase database passwordが含まれるので、環境変数を使います。
dotenvを使うと良いかもしれません。

$ echo -n "Paste your DB password: "; read -s DB_PASSWORD; echo
$ DB_URL="postgres://postgres:${DB_PASSWORD}@db.somewhere.supabase.co:5432/postgres"
$ psql "$DB_URL" -c "\copy public.table TO 'dump.csv' WITH (FORMAT CSV, HEADER)"