Created
June 6, 2011 23:26
-
-
Save jduckles/1011348 to your computer and use it in GitHub Desktop.
simple csv importer to psql
This file contains hidden or 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/sh | |
DBHOST=mydbhost | |
DBNAME=mydbname | |
files=$1 | |
target=$2 | |
for file in ${files}; do | |
psql -h ${DBHOST} ${DBNAME} -c "\copy ${target} FROM '${file}' delimiters ','" | |
done | |
# example usage | |
# csv2psql "$(ls *.out.csv)" someschema.tablename | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment