Created
April 4, 2023 10:21
-
-
Save guyromm/a99b4f3f63ca2f340a46200e5216e9c5 to your computer and use it in GitHub Desktop.
how to import a bunch of JSONL into your all time favorite database (postgresql, duh)
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 | |
F="$1" | |
T="$2" | |
for ((I=0;I<"$(cat "$F" |wc -l)";I=$I+1)) ; do | |
tail -n+$I $F | head -1 > /tmp/1.json | |
(echo '\set l1 `cat /tmp/1.json`' ; echo "insert into "$T" (v) values (:'l1')" ) | ./psql.sh -t -v ON_ERROR_STOP=1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment