trolldb.api.api module

The module which includes the main functionalities of the API package.

This is the main module which is supposed to be imported by the users of the package.

Note

The following applies to the api package and all its subpackages/modules.

To avoid redundant documentation and inconsistencies, only non-FastAPI components are documented via the docstrings. For the documentation related to the FastAPI components, check out the auto-generated documentation by FastAPI. Assuming that the API server is running on http://localhost:8000 (example) the auto-generated documentation can be accessed via either http://localhost:8000/redoc or http://localhost:8000/docs.

Read more at FastAPI automatics docs.

trolldb.api.api.run_server(app_config: AppConfig) None

Runs the API server with connection to the database.

It runs the imported fastapi_app using uvicorn which is ASGI (Asynchronous Server Gateway Interface) compliant. This function runs the event loop using asyncio and does not yield!

Parameters:

app_config – The configuration of the API server and the database.

Example

from trolldb.api.api import run_server
from trolldb.config.config import parse_config

if __name__ == "__main__":
    run_server(parse_config("config.yaml"))