Skip to content

Commit ae62be5

Browse files
authored
Merge pull request #52 from vdice/docs/postgres-example-readmes
docs(examples): add suggested postgres setup
2 parents 217798e + 60b4cfb commit ae62be5

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

examples/postgres-v3/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
This example shows how to access a PostgreSQL database from Spin component.
44

5+
## Prerequisite: Postgres
6+
7+
This example assumes postgres is running and accessible locally via its standard 5432 port.
8+
9+
We suggest running the `postgres` Docker container which has the necessary postgres user permissions
10+
already configured. For example:
11+
12+
```
13+
docker run --rm -h 127.0.0.1 -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres
14+
```
15+
516
## Spin up
617

7-
From example root:
18+
Then, run the following from the root of this example:
819

920
```
10-
createdb spin_dev
11-
psql -d spin_dev -f db/testdata.sql
12-
RUST_LOG=spin=trace spin build --up
21+
createdb -h localhost -U postgres spin_dev
22+
psql -h localhost -U postgres -d spin_dev -f db/testdata.sql
23+
spin build --up
1324
```
1425

1526
Curl the read route:

examples/postgres/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
This example shows how to access a PostgreSQL database from Spin component.
44

5+
## Prerequisite: Postgres
6+
7+
This example assumes postgres is running and accessible locally via its standard 5432 port.
8+
9+
We suggest running the `postgres` Docker container which has the necessary postgres user permissions
10+
already configured. For example:
11+
12+
```
13+
docker run --rm -h 127.0.0.1 -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres
14+
```
15+
516
## Spin up
617

7-
From example root:
18+
Then, run the following from the root of this example:
819

920
```
10-
createdb spin_dev
11-
psql -d spin_dev -f db/testdata.sql
12-
RUST_LOG=spin=trace spin build --up
21+
createdb -h localhost -U postgres spin_dev
22+
psql -h localhost -U postgres -d spin_dev -f db/testdata.sql
23+
spin build --up
1324
```
1425

1526
Curl the read route:

0 commit comments

Comments
 (0)