https://github.com/cybertec-postgresql/pg_remote_exec
Run shell commands in SQL prompt
https://github.com/cybertec-postgresql/pg_remote_exec
postgresql postgresql-extension
Last synced: 6 months ago
JSON representation
Run shell commands in SQL prompt
- Host: GitHub
- URL: https://github.com/cybertec-postgresql/pg_remote_exec
- Owner: cybertec-postgresql
- License: other
- Created: 2016-07-11T11:06:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-11T15:43:31.000Z (over 1 year ago)
- Last Synced: 2024-07-12T15:46:36.861Z (over 1 year ago)
- Topics: postgresql, postgresql-extension
- Language: C
- Homepage:
- Size: 14.6 KB
- Stars: 7
- Watchers: 9
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pg_remote_exec
PostgreSQL extension to allow shell command execution via SQL query.
# INSTALL
Install PostgreSQL before proceeding. Make sure to have `pg_config` binary,
these are typically included in `-dev` and `-devel` packages.
```bash
git clone https://github.com/cybertec-postgresql/pg_remote_exec.git
cd pg_remote_exec
make
sudo make install
```
# CONFIGURE
Execute as superuser:
```
CREATE EXTENSION pg_remote_exec;
```
# USAGE
```
postgres=# SELECT pg_remote_exec('date');
pg_remote_exec
----------------
0
(1 row)
postgres=# SELECT pg_remote_exec_fetch('date', 't');
pg_remote_exec_fetch
───────────────────────────────
Fri Aug 5 17:41:07 EEST 2016
(1 row)
```
# REFERENCE
## Functions
* `pg_remote_exec(text)`: executes the command and returns the shell
exit code.
* `pg_remote_exec_fetch(text, boolean)`: executes the command and returns
output as text. The boolean parameter dictates whether to return output in
case of non-zero exit code.