Skip to content

Commit

Permalink
Merge pull request #52 from vdice/docs/postgres-example-readmes
Browse files Browse the repository at this point in the history
docs(examples): add suggested postgres setup
  • Loading branch information
vdice authored Dec 11, 2024
2 parents 217798e + 60b4cfb commit ae62be5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions examples/postgres-v3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 15 additions & 4 deletions examples/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ae62be5

Please sign in to comment.