惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
腾讯CDC
A
About on SuperTechFans
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
D
DataBreaches.Net
D
Docker
宝玉的分享
宝玉的分享
量子位
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Last Week in AI
Last Week in AI
H
Help Net Security
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Turning PostgreSQL Into an Integration Engine
Gouranga Das Samrat · 2026-05-24 · via DEV Community

I wanted to see how far PostgreSQL extensibility could go.

Most People Think PostgreSQL Is Just a Database, but PostgreSQL is actually a programmable system. With extensions and procedural languages, it can do far more than simply store and retrieve data.

Recently I started thinking about a simple idea:

What if PostgreSQL could call REST APIs directly from SQL queries?

Instead of always relying on a backend service to act as an integration layer, some interactions with external systems might happen directly from the database.

This idea led me to run a small technical experiment.

Project Idea

In most architectures today, integrations usually look like this:

Database → Backend Service → External API

The backend service is responsible for calling APIs, processing responses, and storing results in the database.

But PostgreSQL has something many people forget: extensibility.

It supports:

  • procedural languages (PL/Python, PL/pgSQL, etc.)
  • native extensions written in C
  • custom SQL-callable functions

This raises an interesting possibility:

Could PostgreSQL itself perform HTTP requests?

If that is possible, SQL queries could potentially interact with external services during execution.

Technical Possibility

PostgreSQL allows developers to extend the database with custom functions.

These functions can be implemented using:

  • procedural languages (Python, Perl, etc.)
  • native extensions written in C

That means we can implement a function capable of performing HTTP requests and expose it directly to SQL.

Conceptually, the goal is to enable something like this:

SELECT http_request(
    'httpbin.org',
    443,
    '/headers',
    'GET',
    NULL,
    '{"Authorization":"Bearer demo-token"}'::jsonb,
    true,
    30
);

This query sends an HTTPS request to an external endpoint and returns the response to the SQL session.

Because headers are passed as JSON, they can also be dynamically constructed inside SQL queries.

3. Experiment & Result

To explore the idea, I implemented two different versions of the HTTP function.

Experiment 1 — PL/Python Implementation

The first version uses PL/Python, one of PostgreSQL’s supported procedural languages.

Using Python inside PostgreSQL makes it relatively easy to perform HTTP requests using common Python libraries.

Example usage:

select http.post('https://httpbin.org/post','{"data":{"a": 1,"b": 2}}');

The query triggers an HTTPS request and the response is returned to the SQL client.

To simplify experimentation, this version was packaged as a Docker image with PostgreSQL and PL/Python preconfigured.

Experiment 2 — Native PostgreSQL extension

The second experiment goes deeper by implementing the HTTP functionality as a native PostgreSQL extension written in C.

Extensions written in C integrate directly with the PostgreSQL engine and offer more control over performance and behavior.

This version explores how HTTP capabilities could potentially be embedded closer to the database layer.

Example usage:

SELECT http_request(
    'httpbin.org',
    443,
    '/headers',
    'GET',
    NULL,
    '{"Authorization":"Bearer demo-token"}'::jsonb,
    true,
    30
);

Development Process

Another interesting aspect of this experiment was the development workflow.

I intentionally used AI-assisted development (or what I like to call vibe coding) while building the project, especially when working with PostgreSQL extension code in C.

AI helped accelerate:

  • extension scaffolding
  • exploration of low-level C patterns
  • rapid prototyping
  • documentation

It was interesting to see how AI could help speed up systems-level experimentation, not just application development.

Design Considerations

Allowing a database to call external APIs raises several architectural considerations.

Latency

Database queries are expected to be fast and predictable.
External API calls introduce network latency, which can slow down query execution.

Transaction Behavior

If an HTTP request is executed inside a transaction, the transaction might be blocked while waiting for the external service.

Reliability

External APIs can fail, timeout, or become unavailable.
Proper timeout handling and error management are essential.

Security

Allowing outbound HTTP requests from the database may introduce security concerns, especially if unrestricted endpoints are allowed.

Because of these considerations, this approach should not replace backend services in most production architectures.

However, it can still be useful for:

  • experimentation
  • rapid integration prototypes
  • certain data enrichment scenarios

Final Thoughts

This experiment started with a simple question:

Can the database participate directly in integration workflows?

PostgreSQL’s extensibility makes it a surprisingly powerful playground for exploring ideas like this.

And with modern AI-assisted workflows, experimenting with systems-level concepts has become significantly faster.

I’m still exploring how far the idea of database-driven integrations can go.