erdantic.convenience¶
create
¶
create(
*models_or_modules: Union[type, ModuleType],
terminal_models: Collection[type] = tuple(),
termini: Collection[type] = tuple(),
limit_search_models_to: Optional[Collection[str]] = None
) -> EntityRelationshipDiagram
Construct EntityRelationshipDiagram
from given
data model classes or modules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*models_or_modules |
type | ModuleType
|
Data model classes to add to diagram, or modules to search for data model classes. |
()
|
terminal_models |
Collection[type]
|
Data model classes to set as terminal nodes. erdantic will stop searching for component classes when it reaches these models |
tuple()
|
termini |
Collection[type]
|
Deprecated. Use |
tuple()
|
limit_search_models_to |
Collection[str] | None
|
Plugin identifiers to limit to when searching modules for data model classes. Defaults to None which will not impose any limits. |
None
|
Returns:
Type | Description |
---|---|
EntityRelationshipDiagram
|
diagram object for given data model. |
Raises:
Type | Description |
---|---|
UnknownModelTypeError
|
if a given model does not match any model types from loaded plugins. |
UnresolvableForwardRefError
|
if a model contains a forward reference that cannot be automatically resolved. |
Source code in erdantic/convenience.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
draw
¶
draw(
*models_or_modules: Union[type, ModuleType],
out: Union[str, PathLike],
terminal_models: Collection[type] = tuple(),
termini: Collection[type] = tuple(),
limit_search_models_to: Optional[
Collection[str]
] = None,
graph_attr: Optional[Mapping[str, Any]] = None,
node_attr: Optional[Mapping[str, Any]] = None,
edge_attr: Optional[Mapping[str, Any]] = None,
**kwargs
)
Render entity relationship diagram for given data model classes to file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*models_or_modules |
type | ModuleType
|
Data model classes to add to diagram, or modules to search for data model classes. |
()
|
terminal_models |
Collection[type]
|
Data model classes to set as terminal nodes. erdantic will stop searching for component classes when it reaches these models |
tuple()
|
termini |
Collection[type]
|
Deprecated. Use |
tuple()
|
limit_search_models_to |
Optional[Collection[str]]
|
Plugin identifiers to limit to when searching modules for data model classes. Defaults to None which will not impose any limits. |
None
|
graph_attr |
Mapping[str, Any] | None
|
Override any graph attributes on
the |
None
|
node_attr |
Mapping[str, Any] | None
|
Override any node attributes for all
nodes on the |
None
|
edge_attr |
Mapping[str, Any] | None
|
Override any edge attributes for all
edges on the |
None
|
**kwargs |
Additional keyword arguments to
|
{}
|
Raises:
Type | Description |
---|---|
UnknownModelTypeError
|
if a given model does not match any model types from loaded plugins. |
UnresolvableForwardRefError
|
if a model contains a forward reference that cannot be automatically resolved. |
Source code in erdantic/convenience.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
find_models
¶
find_models(
module: ModuleType,
limit_search_models_to: Optional[
Collection[str]
] = None,
) -> Iterator[type]
Searches a module and yields all data model classes found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module |
ModuleType
|
Module to search for data model classes. |
required |
limit_search_models_to |
Collection[str] | None
|
Plugin identifiers to limit to when searching modules for data model classes. Defaults to None which will not impose any limits. |
None
|
Yields:
Type | Description |
---|---|
Iterator[type]
|
Members of module that are data model classes. |
Raises:
Type | Description |
---|---|
UnknownModelTypeError
|
if a given model does not match any model types from loaded plugins. |
UnresolvableForwardRefError
|
if a model contains a forward reference that cannot be automatically resolved. |
Source code in erdantic/convenience.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
to_dot
¶
to_dot(
*models_or_modules: Union[type, ModuleType],
terminal_models: Collection[type] = [],
termini: Collection[type] = tuple(),
limit_search_models_to: Optional[
Collection[str]
] = None,
graph_attr: Optional[Mapping[str, Any]] = None,
node_attr: Optional[Mapping[str, Any]] = None,
edge_attr: Optional[Mapping[str, Any]] = None
) -> str
Generate Graphviz DOT language representation of entity relationship diagram for given data model classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*models_or_modules |
type | ModuleType
|
Data model classes to add to diagram, or modules to search for data model classes. |
()
|
terminal_models |
Collection[type]
|
Data model classes to set as terminal nodes. erdantic will stop searching for component classes when it reaches these models |
[]
|
termini |
Collection[type]
|
Deprecated. Use |
tuple()
|
limit_search_models_to |
Optional[Collection[str]]
|
Plugin identifiers to limit to when searching modules for data model classes. Defaults to None which will not impose any limits. |
None
|
graph_attr |
Mapping[str, Any] | None
|
Override any graph attributes on
the |
None
|
node_attr |
Mapping[str, Any] | None
|
Override any node attributes for all
nodes on the |
None
|
edge_attr |
Mapping[str, Any] | None
|
Override any edge attributes for all
edges on the |
None
|
Returns:
Type | Description |
---|---|
str
|
DOT language representation of diagram |
Source code in erdantic/convenience.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|