Generate attrs models content using DRF from sqlalchemy models.
Project description
exdrf-gen-al2at
exdrf-gen-al2at is an exdrf-gen plugin that generates attrs-based
Python modules from an ExDataset built from your SQLAlchemy declarative
models. Output is driven by Jinja2 templates under al2at_templates/ and the
composite tree in exdrf_gen.fs_support (TopDir, CategDir, ResFile, …).
Python 3.12.2+ is required.
What it generates
Layout under the output directory:
- Root
__init__.py,api.py - Per category:
{category}/__init__.py,{category}/api.py - Per resource:
{category}/{resource}.pyfromc/m.py.j2
Templates receive out_module, db_module, type_to_attrs, and standard
dataset/resource context from exdrf-gen (see the exdrf-gen README
for fs_support and preserve markers).
Dependencies
Declared in pyproject.toml for this package:
attrs
You also need (same environment as your SQLAlchemy models):
exdrf-gen— shared CLI, Jinja environment,fs_supportexdrf-al—GetDatasetanddataset_from_sqlalchemyfor the DATASET argumentclick— used by the CLI
Install the plugin package in editable or release form alongside those dependencies.
Command-line usage
The command is registered on the shared exdrf_gen Click group. With
exdrf-gen installed:
exdrf-gen al2at DATASET OUT-PATH OUT-MODULE DB-MODULE
Same entry point via python -m exdrf_gen (loads plugins, then the CLI):
python -m exdrf_gen al2at DATASET OUT-PATH OUT-MODULE DB-MODULE
Arguments:
- DATASET —
module.path:Symbolpointing to your SQLAlchemy declarative Base (or equivalent). Resolved byexdrf_al.click_support.GetDataset. - OUT-PATH — output directory (created as needed). Override with env var
EXDRF_AL2AT_PATH. - OUT-MODULE — Python package name for generated imports.
- DB-MODULE — module where SQLAlchemy model classes live (passed into templates).
Global options on the root group include --debug.
Python API
from exdrf_gen_al2at.creator import generate_attrs_from_alchemy
from exdrf_gen.jinja_support import jinja_env
generate_attrs_from_alchemy(
d_set=dataset,
out_path="/path/to/out",
out_module="my_app.generated",
db_module="my_app.db.models",
env=jinja_env,
)
Plugin registration
This package registers:
[project.entry-points.'exdrf.plugins']
exdrf_gen = 'exdrf_gen_al2at'
Importing exdrf_gen_al2at calls install_plugin with the template
directory so jinja_env can resolve al2at_templates.
See also
exdrf-gen—README.md(plugins, Jinja,fs_support)
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
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_al2at-0.1.16.tar.gz.
File metadata
- Download URL: exdrf_gen_al2at-0.1.16.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5119650b6bb1e0df5a906e807f23d6b1a2735cf1d796f9942db56b699c9991f7
|
|
| MD5 |
56f3261b8e403ec9ddd0ab8325029467
|
|
| BLAKE2b-256 |
2d270be24db23f40fcb9b27a9e38ed65577183c524dd6f8e3364a4ea03cfdfaa
|
File details
Details for the file exdrf_gen_al2at-0.1.16-py3-none-any.whl.
File metadata
- Download URL: exdrf_gen_al2at-0.1.16-py3-none-any.whl
- Upload date:
- Size: 5.9 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 |
d6097650ac2365195e2141833370c7847f002195df44b980a6023bd03270693d
|
|
| MD5 |
c1acb4eda142511418073834b8125a79
|
|
| BLAKE2b-256 |
f7be8ae520c7066d51ec9ec217646301541aa5d0da9b1389804639cf48e8e9e4
|