PlanetScale provide a hosted MySQL database with 5GB of storage included in the free tier.

1. Sign up to PlanetScale

Go to https://auth.planetscale.com/sign-up

2. Create a new database

Select New database on the dashboard.

Create a database.

Screenshot 2023-06-25 at 21.43.25.png

Screenshot 2023-06-25 at 21.15.01.png

3. Create a password

Go to SettingsPasswords and click New password.

Screenshot 2023-06-25 at 21.15.41.png

Save the host, username, and password values as Val Town secrets – use planetScaleHost, planetScaleUsername, and planetScalePassword respectively.

Screenshot 2023-06-25 at 21.16.18.png

4. Create your first table

Copy and paste this val to create a table with the given schema.

https://www.val.town/embed/vtdocs.planetScaleCreateStockTable

5. Insert an item

Insert one or more items.

https://www.val.town/embed/vtdocs.planetScaleInsertStockTable

6. Query an item

Use the rows property to get your query results – or return the entire results object to see what other data is available.

https://www.val.town/embed/vtdocs.planetScaleSelectStockTable