I am trying to automate a set of procedures that create TEMPLATE databases.
I have a set of files (file1, file2, ... fileN), each of which contains a set of pgsql com
For that use case where you have to do it....
Here is a script I've used for importing JSON into PostgreSQL (WSL Ubuntu), which basically requires that you mix psql meta commands and SQL in the same command line. Note use of the somewhat obscure script command, which allocates a pseudo-tty:
$ more update.sh
#!/bin/bash
wget .json
echo '\set content `cat $(ls -t .json.* | head -1)` \\ delete from ; insert into values(:'"'content'); refresh materialized view ; " | PGPASSWORD= psql -h -U -d
$
- 热议问题