6
6
import os
7
7
8
8
from 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
+ )
9
17
from utils import get_secret_dict
10
18
11
19
secret = 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" ]),
31
26
)
32
-
33
- postgres_settings = PostgresSettings ()
34
27
db_settings = DatabaseSettings ()
35
28
custom_sql_settings = CustomSQLSettings ()
36
29
@@ -40,20 +33,14 @@ async def startup_event() -> None:
40
33
"""Connect to database on startup."""
41
34
await connect_to_db (
42
35
app ,
43
- settings = postgres_settings ,
44
36
schemas = db_settings .schemas ,
37
+ tipg_schema = db_settings .tipg_schema ,
45
38
user_sql_files = custom_sql_settings .sql_files ,
39
+ settings = postgres_settings ,
46
40
)
47
41
await register_collection_catalog (
48
42
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 ,
57
44
)
58
45
59
46
0 commit comments