Skip to content

Instantly share code, notes, and snippets.

@stefan-matic
Created October 28, 2021 14:29
Show Gist options
  • Save stefan-matic/69799e684c39c65ad27388cb2f4ef6a6 to your computer and use it in GitHub Desktop.
Save stefan-matic/69799e684c39c65ad27388cb2f4ef6a6 to your computer and use it in GitHub Desktop.
Import CSV files into PostgreSQL
#!/bin/bash
# Pass $1 as the table
# Pass $2 as the path to the csv file
psql -h <HOSTNAME> -U postgres -d <DATABASE> -c "\copy ${1} from ${2} delimiter ',' csv header;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment