Skip to content

Commit 671f442

Browse files
committed
upgrade to stac_fastapi.pgstac 5.0 to get new PostgresSettings
1 parent 81d50a2 commit 671f442

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

lib/stac-api/runtime/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
stac-fastapi-pgstac>=4.0.2,<4.1
1+
stac-fastapi-pgstac>=5.0,<5.1
22
starlette-cramjam>=0.4,<0.5

lib/stac-api/runtime/src/handler.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,27 @@
66
import os
77

88
from mangum import Mangum
9+
from stac_fastapi.pgstac.app import app
10+
from stac_fastapi.pgstac.config import PostgresSettings
11+
from stac_fastapi.pgstac.db import close_db_connection, connect_to_db
912
from utils import get_secret_dict
1013

1114
secret = get_secret_dict(secret_arn_env_var="PGSTAC_SECRET_ARN")
12-
13-
os.environ.update(
14-
{
15-
"postgres_host_reader": secret["host"],
16-
"postgres_host_writer": secret["host"],
17-
"postgres_dbname": secret["dbname"],
18-
"postgres_user": secret["username"],
19-
"postgres_pass": secret["password"],
20-
"postgres_port": str(secret["port"]),
21-
}
15+
postgres_settings = PostgresSettings(
16+
postgres_host_reader=secret["host"],
17+
postgres_host_writer=secret["host"],
18+
postgres_dbname=secret["dbname"],
19+
postgres_user=secret["username"],
20+
postgres_pass=secret["password"],
21+
postgres_port=int(secret["port"]),
2222
)
2323

24-
from stac_fastapi.pgstac.app import app
25-
from stac_fastapi.pgstac.db import close_db_connection, connect_to_db
26-
2724

2825
@app.on_event("startup")
2926
async def startup_event():
3027
"""Connect to database on startup."""
3128
print("Setting up DB connection...")
32-
await connect_to_db(app)
29+
await connect_to_db(app, postgres_settings=postgres_settings)
3330
print("DB connection setup.")
3431

3532

0 commit comments

Comments
 (0)