From 60b4cfb8bdf3ef8212a90fcd90977124ae8050d7 Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Wed, 11 Dec 2024 15:33:27 -0700 Subject: [PATCH] docs(examples): add suggested postgres setup Signed-off-by: Vaughn Dice --- examples/postgres-v3/README.md | 19 +++++++++++++++---- examples/postgres/README.md | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/examples/postgres-v3/README.md b/examples/postgres-v3/README.md index ac96316..c80efc1 100644 --- a/examples/postgres-v3/README.md +++ b/examples/postgres-v3/README.md @@ -2,14 +2,25 @@ This example shows how to access a PostgreSQL database from Spin component. +## Prerequisite: Postgres + +This example assumes postgres is running and accessible locally via its standard 5432 port. + +We suggest running the `postgres` Docker container which has the necessary postgres user permissions +already configured. For example: + +``` +docker run --rm -h 127.0.0.1 -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres +``` + ## Spin up -From example root: +Then, run the following from the root of this example: ``` -createdb spin_dev -psql -d spin_dev -f db/testdata.sql -RUST_LOG=spin=trace spin build --up +createdb -h localhost -U postgres spin_dev +psql -h localhost -U postgres -d spin_dev -f db/testdata.sql +spin build --up ``` Curl the read route: diff --git a/examples/postgres/README.md b/examples/postgres/README.md index bdbb303..f4c4d80 100644 --- a/examples/postgres/README.md +++ b/examples/postgres/README.md @@ -2,14 +2,25 @@ This example shows how to access a PostgreSQL database from Spin component. +## Prerequisite: Postgres + +This example assumes postgres is running and accessible locally via its standard 5432 port. + +We suggest running the `postgres` Docker container which has the necessary postgres user permissions +already configured. For example: + +``` +docker run --rm -h 127.0.0.1 -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres +``` + ## Spin up -From example root: +Then, run the following from the root of this example: ``` -createdb spin_dev -psql -d spin_dev -f db/testdata.sql -RUST_LOG=spin=trace spin build --up +createdb -h localhost -U postgres spin_dev +psql -h localhost -U postgres -d spin_dev -f db/testdata.sql +spin build --up ``` Curl the read route: