-
Notifications
You must be signed in to change notification settings - Fork 10k
thomasgauvin: add docs for postgres planetscale #23403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thomasgauvin
merged 7 commits into
production
from
thomasgauvin-hyperdrive-pscale-postgres
Sep 5, 2025
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9b55806
thomasgauvin: add docs for postgres planetscale
thomasgauvin 6779672
thomasgauvin: update pscale postgres
thomasgauvin 7b82112
fix pscale psql snippet
thomasgauvin 2115d96
planetscale cleanup
thomasgauvin 8d651e0
adjust planetscale references throughout docs to include postgres
thomasgauvin 928a298
Update src/content/docs/workers/databases/connecting-to-databases.mdx
Oxyjun 1707122
Update src/content/docs/hyperdrive/examples/connect-to-postgres/postg…
Oxyjun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...amples/connect-to-postgres/postgres-database-providers/planetscale-postgres.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| type: example | ||
| summary: Connect Hyperdrive to a PlanetScale PostgreSQL database. | ||
| pcx_content_type: example | ||
| title: PlanetScale | ||
| sidebar: | ||
| order: 8 | ||
| description: Connect Hyperdrive to a PlanetScale PostgreSQL database. | ||
| --- | ||
|
|
||
| import { Render } from "~/components"; | ||
|
|
||
| This example shows you how to connect Hyperdrive to a [PlanetScale](https://planetscale.com/) PostgreSQL database. | ||
|
|
||
| ## 1. Allow Hyperdrive access | ||
|
|
||
| You can connect Hyperdrive to any existing PlanetScale PostgreSQL database by creating a new role (optional) and retrieving a connection string to your database. | ||
|
|
||
| ### PlanetScale Dashboard | ||
|
|
||
| 1. Go to the [**PlanetScale dashboard**](https://app.planetscale.com/) and select the database you wish to connect to. | ||
| 2. Click **Connect**. | ||
| 3. Create a new role for your Hyperdrive configuration (recommended): | ||
| 1. Ensure the minimum required permissions for Hyperdrive to read and write data to your tables: | ||
| - **pg_read_all_data** - Read data from all tables, views, and sequences | ||
| - **pg_write_all_data** - Write data to all tables, views, and sequences | ||
| 2. Click **Create role**. | ||
| 4. Note the user, the password, the database host, and the database name (or `postgres` as the default database). You will need these to create a database configuration in Hyperdrive. | ||
|
|
||
| With the host, database name, username and password, you can now create a Hyperdrive database configuration. | ||
|
|
||
| ## 2. Create a database configuration | ||
|
|
||
| <Render file="create-hyperdrive-config" product="hyperdrive" /> | ||
|
|
||
| :::note | ||
|
|
||
| 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. | ||
|
|
||
| ::: | ||
|
|
||
| <Render file="create-hyperdrive-config-next-steps" product="hyperdrive" /> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.