flip_api.cohort_services.submit_cohort_query

Attributes

router

FORBIDDEN_COMMANDS

REGEX

Functions

contains_forbidden_commands(→ bool)

Check if the query contains any forbidden commands

validate_query(→ None)

Validate the SQL query syntax

submit_cohort_query(, db, user_id)

Submit a cohort query to all available trusts.

Module Contents

flip_api.cohort_services.submit_cohort_query.router
flip_api.cohort_services.submit_cohort_query.FORBIDDEN_COMMANDS = ['alter user', 'alter table', 'alter database', 'drop table', 'drop user', 'drop role', 'drop...
flip_api.cohort_services.submit_cohort_query.REGEX
flip_api.cohort_services.submit_cohort_query.contains_forbidden_commands(query: str) bool

Check if the query contains any forbidden commands

Parameters:

query – SQL query string

Returns:

True if the query contains forbidden commands, False otherwise

Return type:

bool

flip_api.cohort_services.submit_cohort_query.validate_query(query: str) None

Validate the SQL query syntax

Parameters:

query – SQL query string

Raises:

ValueError – If the query is not valid SQL

flip_api.cohort_services.submit_cohort_query.submit_cohort_query(request: fastapi.Request, cohort_query: flip_api.domain.schemas.cohort.SubmitCohortQuery = Body(...), db: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) flip_api.domain.schemas.cohort.SubmitCohortQueryOutput

Submit a cohort query to all available trusts.

Parameters:
  • request (Request) – HTTP request object.

  • cohort_query (SubmitCohortQuery) – Query details payload.

  • db (Session) – Database session.

  • user_id (UUID) – ID of the authenticated user.

Returns:

The result of the submission to each trust

Return type:

SubmitCohortQueryOutput

Raises:
  • HTTPException – If the query contains forbidden commands, if the SQL syntax is invalid, if no trusts are found,

  • or if there is an error communicating with the trusts.