docs.sheetjs.com/tests/data-postgres.sh
2025-01-05 21:51:20 -05:00

34 lines
892 B
Bash

#!/bin/bash
# https://docs.sheetjs.com/docs/demos/data/postgresql
## NOTE: these steps are for darwin-arm
mkdir sheetjs-pg
cd sheetjs-pg
npm init -y
npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz pg@8.13.1 pg-format@1.0.4
curl -LO https://docs.sheetjs.com/postgresql/SheetJSPG.js
curl -L -O https://docs.sheetjs.com/pres.numbers
for n in 1{2..7}; do
# brew install postgresql@$n
echo $n
# "If you need to have postgresql@$n first in your PATH, run:"
export PATH="/opt/homebrew/opt/postgresql@$n/bin:$PATH"
# "Or, if you don't want/need a background service you can just run:"
nohup env LC_ALL="C" /opt/homebrew/opt/postgresql@$n/bin/postgres -D /opt/homebrew/var/postgresql@$n >/dev/null 2>&1 &
sleep 5
dropdb SheetJSPG
createdb SheetJSPG
node SheetJSPG.js
npx xlsx-cli SheetJSPGExport.xlsx
psql SheetJSPG -c 'SELECT * FROM "Presidents";'
kill $!
done