Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HTTP client inside your PostgreSQL. Easy to install. No compilation required. API-friendly

License

NotificationsYou must be signed in to change notification settings

NikolayS/postgresql-http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple HTTP client inside your PostgreSQL. Easy to install. No compilation required: no gcc, nomake && make install. Uses only standard extension available in any popular Linux distribution. Postgres 9.6+ is required.

Works very fast (see details).BUT:⚠️ be careful calling external/unpredictable resources, because the population of Postgres backends on your server is about of the same size as the population ofSiberian tigers.

Allows GET and POSTS requests in SQL environment:

test=> \xExpanded display ison.test=>select (get).*fromhttp_client.get('http://ya.ru');-[ RECORD1 ]--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------status_code |302status_line | HTTP/1.1302 Foundheaders     | {"P3P":"policyref=\"/w3c/p3p.xml\", CP=\"NON DSP ADM DEV PSD IVDo OUR IND STP PHY PRE NAV UNI\"","Date":"Sat, 29 Oct 2016 00:08:43 GMT","Server":"nginx","Expires":"Sat, 29 Oct 2016 00:08:44 GMT","Location":"https://ya.ru/","Connection":"keep-alive","Set-Cookie":"yandexuid=182183081477699724; Expires=Tue, 27-Oct-2026 00:08:43 GMT; Domain=.ya.ru; Path=/","Cache-Control":"no-cache,no-store,max-age=0,must-revalidate","Last-Modified":"Sat, 29 Oct 2016 00:08:44 GMT","Content-Length":"0"}body        |is_json     | f

Another example, showing work with REST API:

test=> with resultsas (select jsonb_array_elements(get.body::jsonb->'results')as rfromhttp_client.get('http://pokeapi.co/api/v2/pokemon/','{"user-agent":"test-robot"}'::jsonb))select r->>'url'as url, r->>'name'as pokenamefrom resultsorder by pokenamelimit5;                 url                  |  pokename--------------------------------------+------------ http://pokeapi.co/api/v2/pokemon/15/ | beedrill http://pokeapi.co/api/v2/pokemon/9/  | blastoise http://pokeapi.co/api/v2/pokemon/1/  | bulbasaur http://pokeapi.co/api/v2/pokemon/12/ | butterfree http://pokeapi.co/api/v2/pokemon/10/ | caterpie(5 rows)

Installation

Clone the code (git clone ...) and then execute in psql:

begin;\i/path/to/postgresql-http-client/install.sqlcommit;

Uninstallation

\i/path/to/postgresql-http-client/uninstall.sql

About

HTTP client inside your PostgreSQL. Easy to install. No compilation required. API-friendly

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp