66import os
77
88from mangum import Mangum
9+ from tipg .collections import register_collection_catalog
10+ from tipg .database import connect_to_db
11+ from tipg .main import app
12+ from tipg .settings import (
13+ CustomSQLSettings ,
14+ DatabaseSettings ,
15+ PostgresSettings ,
16+ )
917from utils import get_secret_dict
1018
1119secret = get_secret_dict (secret_arn_env_var = "PGSTAC_SECRET_ARN" )
12- os .environ .update (
13- {
14- "postgres_host" : secret ["host" ],
15- "postgres_dbname" : secret ["dbname" ],
16- "postgres_user" : secret ["username" ],
17- "postgres_pass" : secret ["password" ],
18- "postgres_port" : str (secret ["port" ]),
19- }
20- )
21-
22- from tipg .collections import register_collection_catalog # noqa: E402
23- from tipg .database import connect_to_db # noqa: E402
24-
25- # skipping linting rule that wants all imports at the top
26- from tipg .main import app # noqa: E402
27- from tipg .settings import (
28- CustomSQLSettings , # noqa: E402
29- DatabaseSettings , # noqa: E402
30- PostgresSettings , # noqa: E402; noqa: E402
20+ postgres_settings = PostgresSettings (
21+ postgres_host = secret ["host" ],
22+ postgres_dbname = secret ["dbname" ],
23+ postgres_user = secret ["username" ],
24+ postgres_pass = secret ["password" ],
25+ postgres_port = int (secret ["port" ]),
3126)
32-
33- postgres_settings = PostgresSettings ()
3427db_settings = DatabaseSettings ()
3528custom_sql_settings = CustomSQLSettings ()
3629
@@ -40,20 +33,14 @@ async def startup_event() -> None:
4033 """Connect to database on startup."""
4134 await connect_to_db (
4235 app ,
43- settings = postgres_settings ,
4436 schemas = db_settings .schemas ,
37+ tipg_schema = db_settings .tipg_schema ,
4538 user_sql_files = custom_sql_settings .sql_files ,
39+ settings = postgres_settings ,
4640 )
4741 await register_collection_catalog (
4842 app ,
49- schemas = db_settings .schemas ,
50- tables = db_settings .tables ,
51- exclude_tables = db_settings .exclude_tables ,
52- exclude_table_schemas = db_settings .exclude_table_schemas ,
53- functions = db_settings .functions ,
54- exclude_functions = db_settings .exclude_functions ,
55- exclude_function_schemas = db_settings .exclude_function_schemas ,
56- spatial = db_settings .only_spatial_tables ,
43+ db_settings = db_settings ,
5744 )
5845
5946
0 commit comments