# Deploy PlanetScale Postgres and MySQL Straight from Cloudflare!

Hey everyone, it's Shii-chan! Today Cloudflare and PlanetScale got a whole lot cozier, and it makes working with databases even easier, so I'm excited to share it!

## What was announced?

This one comes from the Cloudflare Blog. Cloudflare and PlanetScale are expanding their partnership so you can **create PlanetScale databases directly from the Cloudflare dashboard and API**.

It covers PlanetScale Postgres and MySQL. And starting next month, you'll be able to **bill new databases straight to your Cloudflare account**, so both self-serve and enterprise customers get one consolidated bill. The nice part: credits from the [startup program](https://www.cloudflare.com/forstartups/) and your committed spend can be applied to PlanetScale databases too!

## The story so far

You could already reach external databases from [Cloudflare Workers](https://workers.cloudflare.com/), but the contracts and billing lived apart — PlanetScale on one side, Cloudflare on the other. The big change here is that provisioning and payment now happen inside the Cloudflare experience.

## What changes

The best part is not having to bounce between tools. From the Cloudflare [dashboard](https://dash.cloudflare.com/?to=/:account/workers/hyperdrive?modal=1) you spin up a database in a few clicks, wire it to Workers, and keep billing in one place.

Good news for Postgres fans, too. The original post puts it this way:

> Postgres has risen in developer popularity with its rich tooling ecosystem (ORMs, GUIs, etc) and extensions like pgvector for building vector search in AI-driven applications.

So the rich tooling — ORMs, GUIs — plus extensions like [pgvector](https://github.com/pgvector/pgvector/) for vector search in AI apps all carry over onto Cloudflare.

## Dive Deep

The connector is [Hyperdrive](https://blog.cloudflare.com/how-hyperdrive-speeds-up-database-access/), Cloudflare's database connectivity service that handles connection pooling and query caching for you. To use it, add a [binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/) to your Worker's `wrangler.jsonc`:

```
{
  "hyperdrive": [
    {
      "binding": "DATABASE",
      "id": "AUTO_GENERATED_ID"
    }
  ]
}
```

Then query with a standard Postgres client (the example uses the `pg` library); the connection string comes from the binding.

```javascript
import { Client } from "pg";

const client = new Client({
  connectionString: env.DATABASE.connectionString
});
await client.connect();
const result = await client.query("SELECT * FROM pg_tables");
```

Want it faster? Use Workers [placement hints](https://developers.cloudflare.com/workers/configuration/placement/#configure-explicit-placement-hints) to sit your Worker near the primary database — that can cut latency to single-digit milliseconds.

```
{
  "placement": {
    "region": "aws:us-east-1"
  }
}
```

On price, a single-node PlanetScale Postgres starts at [$5/month](https://planetscale.com/blog/5-dollar-planetscale). Features like [query insights](https://planetscale.com/docs/postgres/monitoring/query-insights), [branching](https://planetscale.com/docs/postgres/branching) for safe deploys, and detailed usage/cost breakdowns are all included in standard [PlanetScale pricing](https://planetscale.com/pricing).

## Wrap-up

- Provision PlanetScale Postgres and MySQL directly from the Cloudflare dashboard and API
- Starting next month, bill to your Cloudflare account and apply startup credits
- Connect via Hyperdrive — just add a binding to `wrangler.jsonc`
- Placement hints near the primary can reach single-digit-millisecond latency
- Single-node Postgres starts at $5/month

Perfect for anyone building on Workers who wants a proper relational database, and for teams that want contracts and billing consolidated on Cloudflare — keep an eye out for next month's release!
