pg_curl
Run curl actions for data transfer in URL syntax
Repository
RekGRpth/pg_curl
https://github.com/RekGRpth/pg_curl
Source
pg_curl-2.4.5.tar.gz
pg_curl-2.4.5.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_curl | 2.4.5 | UTIL | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4090 | pg_curl | No | Yes | No | Yes | No | Yes | - |
| Related | http pg_net pgjwt gzip bzip zstd pgjq pg_smtp_client |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.4.5 | 1817161514 | pg_curl | - |
| RPM | PIGSTY | 2.4.5 | 1817161514 | pg_curl_$v | - |
| DEB | PIGSTY | 2.4.5 | 1817161514 | postgresql-$v-pg-curl | - |
Build
You can build the RPM / DEB packages for pg_curl using pig build:
pig build pkg pg_curl # build RPM / DEB packages
Install
You can install pg_curl directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_curl; # Install for current active PG version
pig ext install -y pg_curl -v 18 # PG 18
pig ext install -y pg_curl -v 17 # PG 17
pig ext install -y pg_curl -v 16 # PG 16
pig ext install -y pg_curl -v 15 # PG 15
pig ext install -y pg_curl -v 14 # PG 14
dnf install -y pg_curl_18 # PG 18
dnf install -y pg_curl_17 # PG 17
dnf install -y pg_curl_16 # PG 16
dnf install -y pg_curl_15 # PG 15
dnf install -y pg_curl_14 # PG 14
apt install -y postgresql-18-pg-curl # PG 18
apt install -y postgresql-17-pg-curl # PG 17
apt install -y postgresql-16-pg-curl # PG 16
apt install -y postgresql-15-pg-curl # PG 15
apt install -y postgresql-14-pg-curl # PG 14
Create Extension:
CREATE EXTENSION pg_curl;
Usage
CREATE EXTENSION pg_curl;
Perform HTTP Get:
-- wrap curl http get
CREATE OR REPLACE FUNCTION get(url TEXT) RETURNS TEXT LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_url(url),
curl_easy_perform(),
curl_easy_getinfo_data_in()
) SELECT convert_from(curl_easy_getinfo_data_in, 'utf-8') FROM s;
$BODY$;
SELECT get('https://www.postgresql.org/');
Perform Email SMTP:
CREATE OR REPLACE FUNCTION email(url TEXT, username TEXT, password TEXT, subject TEXT, sender TEXT, recipient TEXT, body TEXT, type TEXT) RETURNS TEXT LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_mail_from(sender),
curl_easy_setopt_password(password),
curl_easy_setopt_url(url),
curl_easy_setopt_username(username),
curl_header_append('From', sender),
curl_header_append('Subject', subject),
curl_header_append('To', recipient),
curl_mime_data(body, type:=type),
curl_recipient_append(recipient),
curl_easy_perform(),
curl_easy_getinfo_header_in()
) SELECT curl_easy_getinfo_header_in FROM s;
$BODY$;
Perform FTP download:
CREATE OR REPLACE FUNCTION download(url TEXT, username TEXT, password TEXT) RETURNS BYTEA LANGUAGE SQL AS $BODY$
WITH s AS (SELECT
curl_easy_reset(),
curl_easy_setopt_password(password),
curl_easy_setopt_url(url),
curl_easy_setopt_username(username),
curl_easy_perform(),
curl_easy_getinfo_data_in()
) SELECT curl_easy_getinfo_data_in FROM s;
$BODY$;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.