parsers
Parse a Pydantic model so it is usable by SQLAlchemy.
is_pydantic(obj)
Checks whether an object is pydantic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj |
object
|
An arbitrary Python object to evaluate |
required |
Returns
(bool): `True` if `obj` is of Pydantic type `ModelMetaClass`
(bool): `False` if `obj` is not of Pydatic type `ModelMetaClass`
Source code in src/red_utils/ext/pydantic_utils/parsers.py
parse_pydantic_schema(schema)
Iterates through pydantic schema and parses nested schemas to a dictionary containing SQLAlchemy models. Only works if nested schemas have specified the Meta.orm_model.
Make sure to add this line to Pydantic schemas that have an ORM class: