Hyperdrive Finally Connects Python Workers to Postgres and MySQL!
Hi, it's me! Here's a piece of news Python Workers fans have probably been waiting for.
Cloudflare ChangelogWhat was announced?
Cloudflare's Changelog announced that Python Workers can now connect to PostgreSQL and MySQL through Hyperdrive. The full setup steps, code examples, and limitations are documented in "Use Hyperdrive from Python Workers."
Why it matters
Python Workers is still a young runtime, and connecting to relational databases has been an evolving story. Hyperdrive's connection pooling and query caching have long been familiar to JavaScript/TypeScript Workers developers, so bringing that same capability to Python Workers is a meaningful step toward building serious database-backed apps in Python on Workers.
What changes
You can now connect a Python Worker to PostgreSQL or MySQL using drivers you already know:
- PostgreSQL: asyncpg (recommended), pg8000, psycopg
- MySQL: aiomysql (recommended), pymysql
Connections go over TCP sockets, so a lot of your existing application code and library usage carries over as-is.
Dive Deep
You'll need a compatibility date of 2026-09-08 or later. The setup flow looks like this:
- Add a Hyperdrive binding and the compatibility flag to your Wrangler config
- Install the driver for the database you want to use
- Deploy with
uv run pywrangler deploy
A few current limitations are worth knowing:
- Async SQLAlchemy ORM isn't supported yet (sync only)
- Some low-level socket operations aren't supported
- Socket operations in Python Workers don't block the event loop, so it's recommended to use locking when doing synchronous operations
This is still a beta feature — Cloudflare is asking people to report issues in the #python-workers channel on the Cloudflare Developers Discord.
Wrap-up
- Python Workers can now connect to PostgreSQL and MySQL through Hyperdrive
- PostgreSQL supports asyncpg (recommended), pg8000, and psycopg; MySQL supports aiomysql (recommended) and pymysql
- Requires compatibility date
2026-09-08or later, deployed withuv run pywrangler deploy - Still has beta-era limitations, like no async SQLAlchemy ORM support
- A must-know update if you're building database-backed Python Worker apps!