db
stac_fastapi.pgstac.db ¶
Database connection handling.
DB ¶
DB class that can be used with context manager.
Source code in stac_fastapi/pgstac/db.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
create_pool
async
¶
create_pool(connection_string: str, settings)
Create a connection pool.
Source code in stac_fastapi/pgstac/db.py
144 145 146 147 148 149 150 151 152 153 154 155 |
|
close_db_connection
async
¶
close_db_connection(app: FastAPI) -> None
Close connection.
Source code in stac_fastapi/pgstac/db.py
73 74 75 76 |
|
con_init
async
¶
con_init(conn)
Use orjson for json returns.
Source code in stac_fastapi/pgstac/db.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
connect_to_db
async
¶
connect_to_db(
app: FastAPI,
get_conn: Optional[ConnectionGetter] = None,
postgres_settings: Optional[PostgresSettings] = None,
) -> None
Create connection pools & connection retriever on application.
Source code in stac_fastapi/pgstac/db.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
dbfunc
async
¶
Wrap PLPGSQL Functions.
Keyword arguments: pool -- the asyncpg pool to use to connect to the database func -- the name of the PostgreSQL function to call arg -- the argument to the PostgreSQL function as either a string or a dict that will be converted into jsonb
Source code in stac_fastapi/pgstac/db.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
get_connection
async
¶
get_connection(request: Request, readwrite: Literal['r', 'w'] = 'r') -> AsyncIterator[Connection]
Retrieve connection from database conection pool.
Source code in stac_fastapi/pgstac/db.py
79 80 81 82 83 84 85 86 87 88 |
|
translate_pgstac_errors ¶
translate_pgstac_errors() -> Generator[None, None, None]
Context manager that translates pgstac errors into FastAPI errors.
Source code in stac_fastapi/pgstac/db.py
121 122 123 124 125 126 127 128 129 130 131 132 133 |
|