跳到正文
文章入门

用 Cloudflare Workers 连接 PostgreSQL 数据库

通过 TCP Sockets 和 Hyperdrive 让 Cloudflare Worker 连接 PostgreSQL 数据库,并对商品表进行查询和插入。

最近更新
2026年10月12日
阅读原文

该介绍目前仅提供英文版本。

Create a Workers application that talks to an existing PostgreSQL database using TCP Sockets, then speed up connections with Hyperdrive. The Worker reads from and writes to a products table.

What you’ll learn

  • Add a PostgreSQL client library to a Worker
  • Configure and open the database connection
  • Query and insert rows
  • Deploy, then add Hyperdrive for pooled, faster connections

Cloudflare products used

Workers, Hyperdrive.

Follow the full, step-by-step tutorial in Cloudflare’s documentation.

继续学习