run_query
- specatalog.crud_db.read.run_query(filters, ordering=None)[source]
Query the database. The table is chosen from the filter model. All filters and the ordering is organised in filter and ordering models.
- Parameters:
filters (filter_model) – Pydantic model from one of the Filter-classes. The class that is chosen determines which table is searched. If e.g. an object of the class TREPRFilter is used only trEPR-measurements are searched.
ordering (ordering_model, optional) – The list of results may be ordered depending on one or muliple ordering parameters that are organised in an ordering model. For each parameter “asc” (ascending) or “desc” (descending) order can (but does not have to) be chosen. The default is None, which means that no ordering of the results is applied.
- Raises:
ValueError – An error is raised if the filter or the ordering model contains attributes that are not part of the queried table.
- Returns:
Results of the query. The lists contains objects of the sqlalchemy model type.
- Return type:
list