Complete knowledge domain for Cloudflare Hyperdrive - connecting Cloudflare Workers to existing PostgreSQL and MySQL databases with global connection pooling, query caching, and reduced latency. Use when: connecting Workers to existing databases, migrating PostgreSQL/MySQL to Cloudflare, setting up connection pooling, configuring Hyperdrive bindings, using node-postgres/postgres.js/mysql2 drivers, integrating Drizzle ORM or Prisma ORM, or encountering "Failed to acquire a connection from the pool", "TLS not supported by the database", "connection refused", "nodejs_compat missing", "Code generation from strings disallowed", or Hyperdrive configuration errors. Keywords: hyperdrive, cloudflare hyperdrive, workers hyperdrive, postgres workers, mysql workers, connection pooling, query caching, node-postgres, pg, postgres.js, mysql2, drizzle hyperdrive, prisma hyperdrive, workers rds, workers aurora, workers neon, workers supabase, database acceleration, hybrid architecture, cloudflare tunnel database, wrangler hyperdrive, hyperdrive bindings, local development hyperdrive
Complete knowledge domain for Cloudflare Hyperdrive - Connect Cloudflare Workers to existing PostgreSQL and MySQL databases with global connection pooling, query caching, and reduced latency.
This skill provides complete Hyperdrive knowledge including:
| Issue | Description | Prevention | |-------|-------------|------------| | "nodejs_compat" flag missing | Worker crashes with "No such module" error | Always include nodejs_compat in compatibility_flags | | TLS not supported error (2012) | Database doesn't have SSL enabled | Ensure database has TLS/SSL enabled before creating Hyperdrive config | | Connection refused (2011) | Firewall blocking Hyperdrive | Allow public internet connections or use Cloudflare Tunnel | | Failed to acquire connection | Connection pool exhausted | Use ctx.waitUntil() for cleanup, avoid long-running transactions | | mysql2 eval() error | mysql2 uses eval() which is blocked | Set disableEval: true in mysql2 connection config | | Connection limit exceeded | Workers limit: 6 concurrent connections | Set max: 5 for pg.Pool to stay within limits | | Queries not cached | postgres.js configured with prepare: false | Enable prepared statements with prepare: true | | Invalid credentials (2013) | Username or password incorrect | Verify credentials are correct (case-sensitive password) | | Private IP not supported (2009) | Trying to connect to 192.168.x.x or 10.x.x.x | Use Cloudflare Tunnel for private database access | | Database doesn't exist (2014) | Wrong database name in connection string | Verify database (not table) name exists |
import { Client } from "pg";
type Bindings = {
HYPERDRIVE: Hyperdrive;
};
export default {
async fetch(request: Request, env: Bindings, ctx: ExecutionContext) {
// Connect to PostgreSQL via Hyperdrive
const client = new Client({
connectionString: env.HYPERDRIVE.connectionString
});
await client.connect();
try {
// Query your database
const result = await client.query('SELECT * FROM users LIMIT 10');
return Response.json({
users: result.rows,
// Hyperdrive metadata
origin: env.HYPERDRIVE.host,
cacheStatus: request.cf?.cacheStatus
});
} finally {
// Clean up connection after response is sent
ctx.waitUntil(client.end());
}
}
};
wrangler.jsonc:
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2024-09-23",
"compatibility_flags": ["nodejs_compat"],
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<your-hyperdrive-id>"
}
]
}
Create Hyperdrive config:
npx wrangler hyperdrive create my-database \
--connection-string="postgres://user:password@host:5432/database"
Without this skill:
With this skill:
PostgreSQL: AWS RDS/Aurora, Google Cloud SQL, Azure Database, Neon, Supabase, PlanetScale, Timescale, CockroachDB, Materialize, Fly.io, pgEdge, Prisma Postgres
MySQL: AWS RDS/Aurora, Google Cloud SQL, Azure Database, PlanetScale
Use this skill when you see keywords like:
npx skills add jackspace/Cloudflare Hyperdrive下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer