Skip to content

Commit 9b55806

Browse files
committed
thomasgauvin: add docs for postgres planetscale
1 parent 0afa967 commit 9b55806

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
type: example
3+
summary: Connect Hyperdrive to a PlanetScale PostgreSQL database.
4+
pcx_content_type: example
5+
title: PlanetScale
6+
sidebar:
7+
order: 8
8+
description: Connect Hyperdrive to a PlanetScale PostgreSQL database.
9+
---
10+
11+
import { Render } from "~/components";
12+
13+
This example shows you how to connect Hyperdrive to a [PlanetScale](https://planetscale.com/) PostgreSQL database.
14+
15+
<Render file="planetscale-postgres-partial" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
{}
3+
---
4+
5+
import { Render } from "~/components";
6+
7+
## 1. Allow Hyperdrive access
8+
9+
You can connect Hyperdrive to any existing PlanetScale PostgreSQL database by creating a new user (optional) and retrieving a connection string to your database.
10+
11+
### PlanetScale Dashboard
12+
13+
1. Go to the [**PlanetScale dashboard**](https://app.planetscale.com/) and select the Postgres database you wish to connect to.
14+
2. Click **Connect**. Enter `hyperdrive-user` as the password name (or your preferred name) and configure the permissions as desired. Select **Create password**. Note the username and password as they will not be displayed again.
15+
3. Select **Other** as your language or framework. Note down the database host, database name, database username, and password. You will need these to create a database configuration in Hyperdrive.
16+
17+
With the host, database name, username and password, you can now create a Hyperdrive database configuration.
18+
19+
## 2. Create a database configuration
20+
21+
<Render file="create-hyperdrive-config" product="hyperdrive" />
22+
23+
:::note
24+
25+
When connecting to a PlanetScale PostgreSQL database with Hyperdrive, you should use a driver like [node-postgres (pg)](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres/) or [Postgres.js](/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js/) to connect directly to the underlying database instead of the [PlanetScale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver). Hyperdrive is optimized for database access for Workers and will perform global connection pooling and fast query routing by connecting directly to your database.
26+
27+
:::
28+
29+
<Render file="create-hyperdrive-config-next-steps" product="hyperdrive" />

0 commit comments

Comments
 (0)