Created
October 28, 2021 14:29
-
-
Save stefan-matic/69799e684c39c65ad27388cb2f4ef6a6 to your computer and use it in GitHub Desktop.
Import CSV files into PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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