Cloudflare Lets Python Apps Reuse Existing Databases

Python Workers can connect through Hyperdrive. Check what that changes for an existing database, app architecture and hosting bill.

Wednesday, September 16, 2026Omid Saffari
Cloudflare Lets Python Apps Reuse Existing Databases

On September 16, 2026, Cloudflare gave Python Workers a direct route to PostgreSQL and MySQL through Hyperdrive. If your Worker needed a separate HTTP service only to reach an existing database, that service may now be removable, which changes both the architecture and the monthly bill.

The Database Can Stay Where It Is

The useful part of this release is what you no longer have to move.

Hyperdrive is a managed connection layer between a Cloudflare Worker and an existing PostgreSQL or MySQL database. It isn't a new database, and it doesn't copy your records into Cloudflare. Your Python code opens a TCP connection with a normal database driver, using connection details supplied by a Hyperdrive binding. Hyperdrive handles the long-lived pool of connections to the database behind it.

That changes the common workaround. A Python Worker that couldn't use its database path directly might call a small API or server whose only job was to run SQL. The route looked like this:

Before: Python Worker → database bridge → PostgreSQL or MySQL

Now: Python Worker → Hyperdrive → PostgreSQL or MySQL

Cloudflare performs connection setup near the Worker and keeps pooled connections near the origin database. Its Hyperdrive guide counts seven round trips in a conventional setup before the first query: one for TCP, three for TLS, and three for database authentication. Reusing the pool avoids repeating that full setup for each short-lived Worker invocation.

Architecture showing a Python Worker reaching an existing database through Hyperdrive while the old database-only bridge is removed
The database stays. Hyperdrive can replace a bridge whose only job was carrying database traffic.

The supported path is specific. Python Workers need a compatibility date of 2026-09-08 or later, and the feature is still beta. Cloudflare has tested asyncpg, pg8000, and psycopg for PostgreSQL, plus aiomysql and pymysql for MySQL. asyncpg and aiomysql are the recommended drivers.

Cloudflare says other TCP drivers may work. That isn't the same as promising that every package, ORM, or existing application will work. Database compatibility gets you to the first gate, not through the whole migration.

The Budget Line That Changed

The cleanest cost win appears when you already run the Python app on Workers and pay for a bridge only because the Worker needs database access.

The math is simple:

Current monthly cost = database + Worker + bridge host

Possible monthly cost = database + Worker

Your database bill remains. Hyperdrive's built-in connection pooling and query caching add no separate charge on Workers Paid, and Hyperdrive has no egress charge. If the account already sits inside its included Workers usage, the Cloudflare increment for this connection path is therefore $0. The possible cash saving is the bridge host bill that actually disappears.

Maintenance is part of the same calculation. Removing that bridge can also remove one deployment, one health check, one set of secrets, one log stream, and one failure boundary. Do not assign a dollar value to that work until you know who maintains it and how often it causes trouble.

For a new paid account, Workers Paid starts at $5 per account per month. That includes 10 million requests and 30 million CPU milliseconds each month. Overage is $0.30 per additional million requests and $0.02 per additional million CPU milliseconds. Hyperdrive database queries are listed as unlimited on that plan.

The Free plan can carry a small proof. It includes 100,000 Worker requests per day and 100,000 Hyperdrive database queries per day, with 10 milliseconds of CPU time per invocation. Those are separate counters. One request that runs several SQL statements can consume several database queries.

Who Can Use This Tomorrow

A Solo Founder With a FastAPI Service

Say a founder has a FastAPI Worker in front of a managed PostgreSQL database, plus a tiny container that accepts HTTP calls and runs SQL. If that container contains no business logic, a test with asyncpg can show whether Hyperdrive can replace it.

The payoff isn't a new database. It is keeping the current schema, backups, and provider while deleting a service that existed only as a connection adapter. The founder should migrate one route first, compare its result and latency, then remove the bridge after production behavior matches.

A Small Agency With Client MySQL Databases

A small agency may maintain several narrow Python APIs, each pointed at a client's MySQL database. The new path lets the agency test aiomysql or pymysql inside the Worker instead of deploying a database proxy beside every qualifying app.

The payoff is operational consistency. The agency can use one Worker deployment path and one Hyperdrive configuration per database. The bridge still stays when it performs tenant authorization, schema translation, auditing, or other work beyond passing queries through.

A Platform Team Moving One Read-Heavy Endpoint

A platform team does not have to migrate its whole backend. It can move one public, read-heavy Python endpoint to Workers, keep the regional database, and let Hyperdrive pool the origin connections.

This is also where caching needs an explicit decision. Hyperdrive caches eligible reads by default for 60 seconds and may serve a stale result for another 15 seconds while it revalidates. Public catalog or content reads may tolerate that. Authentication, permissions, billing state, and reads immediately after a write should use a separate cache-disabled Hyperdrive configuration.

The earlier Django versus FastAPI comparison still helps with framework choice. This release changes one part of that decision: keeping PostgreSQL or MySQL is now a documented Python Worker path, but it does not certify the rest of a Django or FastAPI application.

Build the Smallest Safe Connection Test

Use a non-production MySQL database and a limited test user. The goal is to prove the connection path with SELECT 1, not to rehearse a full migration against customer data.

Create a cache-disabled Hyperdrive configuration so the first test measures a fresh database round trip:

Bash
npx wrangler hyperdrive create python-db-test --connection-string="mysql://user:password@HOSTNAME_OR_IP_ADDRESS:PORT/database_name" --caching-disabled

Copy the configuration ID from Wrangler into wrangler.toml. The date below is later than the required 2026-09-08 minimum:

TOML
name = "python-hyperdrive"
main = "src/main.py"
compatibility_date = "2026-09-16"
compatibility_flags = ["python_workers"]

[[hyperdrive]]
binding = "HYPERDRIVE"
id = "<HYPERDRIVE_CONFIG_ID>"

Add the driver to pyproject.toml:

TOML
[project]
dependencies = [
    "aiomysql",
]

Then use Cloudflare's documented connection test in src/main.py:

Python
import aiomysql
from workers import Response, WorkerEntrypoint


class Default(WorkerEntrypoint):
    async def fetch(self, request):
        hd = self.env.HYPERDRIVE
        connection = await aiomysql.connect(
            host=hd.host,
            port=int(hd.port),
            user=hd.user,
            password=hd.password,
            db=hd.database,
            ssl=None,
        )
        try:
            cursor = await connection.cursor()
            await cursor.execute("SELECT 1")
            result = await cursor.fetchone()
            return Response.json({"result": result[0]})
        finally:
            connection.close()

Deploy it with the documented Python Workers command:

Bash
uv run pywrangler deploy

The line that often looks wrong is ssl=None. That is the driver connection from the Worker to Hyperdrive in Cloudflare's example. Hyperdrive's connection to the origin database still requires TLS, and insecure plaintext origin connections are not supported.

The Bridge Is Optional, Not Automatically Obsolete

The launch changes a connection path. It does not turn Python Workers into an unrestricted CPython server.

Python package support covers pure Python packages, PyEmscripten wheels, and packages included with Pyodide. Cloudflare still calls WebAssembly package support early, so a missing dependency can stop the migration. The driver and ORM documentation currently supports synchronous SQLAlchemy only. Async SQLAlchemy is not supported because the Workers environment lacks greenlet support.

The database protocol has its own walls. Hyperdrive supports PostgreSQL 9.0 through 17.x and MySQL 5.7 through 8.x, plus MariaDB. It does not support SQL Server or MongoDB. PostgreSQL advisory locks and LISTEN or NOTIFY are out. MySQL multi-statement queries and protocol-level prepared statements are out. A 60-second maximum query duration applies on both Free and Paid.

Pooling changes session assumptions too. Hyperdrive uses transaction pooling, which means the origin connection returns to the pool when the transaction ends. Code that expects session state to survive across transactions needs review. Long transactions can also exhaust the pool and erase the concurrency benefit.

The Monday Move

Do not migrate the application on Monday. Prove whether one database-only bridge deserves to exist.

  1. Pick one disposable path

    Create a non-production database or replica with a limited user. Choose one route that reads a harmless record and does not depend on session state, locks, or fresh-after-write behavior.

  2. Run the connection smoke test

    Deploy the small Worker above and confirm that SELECT 1 succeeds through Hyperdrive. Record the Worker error rate, CPU time, wall time, and database connection count.

  3. Exercise the real driver and query

    Replace the smoke query with the route's actual driver and one representative query. Check the returned data, transaction behavior, cache setting, and pool usage against the current bridge.

  4. Price the deletion

    Write down the bridge's monthly host bill and the hours spent deploying, patching, monitoring, and recovering it. Subtract any added Workers usage and the ongoing Hyperdrive work. Delete the bridge only when that number and the compatibility test both say yes.

Act this week if the bridge exists only for database access, the app uses PostgreSQL or MySQL, and a tested driver covers the route. Wait if you rely on async SQLAlchemy, an unavailable package, unsupported SQL behavior, or strict read-after-write consistency you have not separated. You are unaffected if the app is staying on its current server or the bridge carries business logic that Hyperdrive does not replace.

For the next platform change translated into a Monday decision, join the newsletter.

Last Updated
Sep 16, 2026
Category
Explained

Prefer this site in Google

Add omidsaffari.com as a preferred source in Google Search

Mark omidsaffari.com as preferred and Google lifts it in Top Stories, AI Overviews and AI Mode for you.

Gemini 3.8 Live Keeps Callers Talking During Lookups

Gemini 3.8 Live Keeps Callers Talking During Lookups

Gemini 3.8 Live runs tools during voice calls. See what changes for booking flows, customer updates and the cost of a completed task.Sep 16, 2026Explained
Cloudflare Limits What a Client's Deploy Agent Can Change

Cloudflare Limits What a Client's Deploy Agent Can Change

Cloudflare adds access controls for individual Workers. See how to separate debugging, code review and deployment rights across client projects.Sep 15, 2026Explained
Claude Code Stops One Install From Widening the Whole Job

Claude Code Stops One Install From Widening the Whole Job

Claude Code can approve network hosts for one command at a time. See what that changes for dependency installs and unattended build jobs.Sep 15, 2026Explained
Vercel AI SDK Can Move Agent Spend to Existing Plans

Vercel AI SDK Can Move Agent Spend to Existing Plans

Vercel AI SDK can use supported agent subscriptions. Check which credentials win, which allowance pays, and what sandbox costs remain.Sep 15, 2026Explained
Cloudflare Browser Run Keeps Client Jobs on Approved Hosts

Cloudflare Browser Run Keeps Client Jobs on Approved Hosts

Limit client browser jobs to approved hosts, budget for required CDNs, and let reviewers watch through read-only Live View.Sep 14, 2026Explained
GPT-Live-1 Changes the Budget for AI Phone Calls

GPT-Live-1 Changes the Budget for AI Phone Calls

Understand GPT-Live-1 phone-agent costs: the voice layer, backend reasoning, telephony, and the interruption handling worth testing.Sep 14, 2026Explained
ChatGPT Appshots Cut Context Copying on Windows

ChatGPT Appshots Cut Context Copying on Windows

Use ChatGPT Appshots on Windows to share an app window, reduce context copying, and check what text and images enter the chat.Sep 14, 2026Explained
Vercel FastAPI Cuts Function Use for Static Files

Vercel FastAPI Cuts Function Use for Static Files

Vercel now serves eligible FastAPI assets from its CDN. See which requests stop using Functions and which protected paths still need them.Sep 13, 2026Explained
Newsletter

One letter, every Sunday.Working systems, not hot takes.

Weekly. No spam. Unsubscribe anytime.