You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-database-providers/planetscale-postgres.mdx
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,4 +12,31 @@ import { Render } from "~/components";
12
12
13
13
This example shows you how to connect Hyperdrive to a [PlanetScale](https://planetscale.com/) PostgreSQL database.
14
14
15
-
<Renderfile="planetscale-postgres-partial" />
15
+
## 1. Allow Hyperdrive access
16
+
17
+
You can connect Hyperdrive to any existing PlanetScale PostgreSQL database by creating a new role (optional) and retrieving a connection string to your database.
18
+
19
+
### PlanetScale Dashboard
20
+
21
+
1. Go to the [**PlanetScale dashboard**](https://app.planetscale.com/) and select the database you wish to connect to.
22
+
2. Click **Connect**.
23
+
3. Create a new role for your Hyperdrive configuration (recommended):
24
+
1. Ensure the minimum required permissions for Hyperdrive to read and write data to your tables:
25
+
-**pg_read_all_data** - Read data from all tables, views, and sequences
26
+
-**pg_write_all_data** - Write data to all tables, views, and sequences
27
+
2. Click **Create role**.
28
+
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.
29
+
30
+
With the host, database name, username and password, you can now create a Hyperdrive database configuration.
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.
0 commit comments