Skip to main content

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). Generated modules pair with exdrf-gen-al2r when you want matching FastAPI routers.

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_on FK scalars, read_only, audit names created_on / updated_on, and the lone PK when is_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 only XxxCreate is 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.

  • DATASETmodule.path:DeclarativeBase for SQLAlchemy (same as other al2* plugins).
  • OUT-PATH — required unless EXDRF_AL2PD_PATH is 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-genREADME.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 Distribution

exdrf_gen_al2pd-0.1.17.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exdrf_gen_al2pd-0.1.17-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file exdrf_gen_al2pd-0.1.17.tar.gz.

File metadata

  • Download URL: exdrf_gen_al2pd-0.1.17.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for exdrf_gen_al2pd-0.1.17.tar.gz
Algorithm Hash digest
SHA256 aff20f3a2bdcf865dd0384f69b892cebbc1ac33f1709d3307c67058b3a379eba
MD5 80919d9e8e1c3ab1cd3ddf0699b54a53
BLAKE2b-256 86b2e31cc1ea1f53e522494e3d73ee55b1381b8544839d2aedbe0bc59d1029ab

See more details on using hashes here.

File details

Details for the file exdrf_gen_al2pd-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for exdrf_gen_al2pd-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 1dcc55b599eeb0b8c925e72eeb17e06f0a4cf03280888da3baabd03b6f3ba80d
MD5 bb6d9bf367a1e3b886ecccf293923ac9
BLAKE2b-256 6bb8ba406d7d567c31f4a634b3996af681028621ae878c7efe6922e502ae4f32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page