Generate pydantic models content using DRF from sqlalchemy models.
Project description
exdrf-gen-al2pd
exdrf-gen-al2pd is an exdrf-gen plugin that generates Pydantic
ExModel classes from SQLAlchemy-backed ExDataset metadata (same field
partitioning idea as bk-one db2m).
Python 3.12.2+ is required.
Generated models per resource
For each ExResource the emitter writes one module (snake-case plural
stem, e.g. widgets.py) under the resource’s category path containing:
Xxx— label fields (minimum_field_set) plus primary keys.XxxEx(Xxx)— extra scalars and relations (PagedList[Related]/ optional nested related label types), with forward refs where needed.XxxCreate— writable create payload: excludes derived columns,depends_onFK scalars,read_only, audit namescreated_on/updated_on, and the lone PK whenis_primary_simple. To-many relations use{rel}_ids(single related PK) or{rel}_keys(list[dict[str, Any]]for composite related PKs).XxxEdit— same payload rules for updates but no primary-key fields. Omitted when the resource is a composite-PK link with only PK scalars (then onlyXxxCreateis emitted).
The package also writes api.py at the output root with re-exports, and
adds __init__.py files so the tree is importable as a package.
Command-line usage
exdrf-gen al2pd DATASET OUT-PATH
Or: python -m exdrf_gen al2pd DATASET OUT-PATH.
- DATASET —
module.path:DeclarativeBasefor SQLAlchemy (same as other al2* plugins). - OUT-PATH — required unless
EXDRF_AL2PD_PATHis set; directory for generated Python modules.
Dependencies
See pyproject.toml: exdrf, exdrf-al, exdrf-gen, exdrf-pd,
click, pydantic.
Plugin registration
[project.entry-points.'exdrf.plugins']
exdrf_gen = 'exdrf_gen_al2pd'
See also
exdrf-gen-al2r— FastAPI routers that import these schemas.exdrf-gen—README.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exdrf_gen_al2pd-0.1.14-py3-none-any.whl.
File metadata
- Download URL: exdrf_gen_al2pd-0.1.14-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e7fb60905ce905e597276a4f7432e3d0f861ab6d70c571866c57eaa2e95e9c6
|
|
| MD5 |
73b9a7747b4a1439960e02c6395c6441
|
|
| BLAKE2b-256 |
21773111196ceb835ac1c7825b290383c853fef65e9be61f8f338ad7f983e6c0
|