fastapifromfrictionless 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapifromfrictionless-0.1.0/LICENSE +21 -0
- fastapifromfrictionless-0.1.0/PKG-INFO +198 -0
- fastapifromfrictionless-0.1.0/README.md +171 -0
- fastapifromfrictionless-0.1.0/doc/__init__.py +0 -0
- fastapifromfrictionless-0.1.0/doc/app.py +395 -0
- fastapifromfrictionless-0.1.0/doc/database.py +11 -0
- fastapifromfrictionless-0.1.0/doc/models.py +286 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/__init__.py +12 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/app.py +99 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/cli.py +110 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/database.py +42 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/load.py +351 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/logging_config.py +33 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/model.py +212 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/templates/app_header.py.jinja2 +110 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/templates/database.py.jinja2 +13 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/templates/endpoint_block.py.jinja2 +55 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/templates/model_block.py.jinja2 +54 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/templates/models_header.py.jinja2 +27 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless/validate.py +70 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/PKG-INFO +198 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/SOURCES.txt +33 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/dependency_links.txt +1 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/entry_points.txt +2 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/requires.txt +14 -0
- fastapifromfrictionless-0.1.0/fastapifromfrictionless.egg-info/top_level.txt +2 -0
- fastapifromfrictionless-0.1.0/pyproject.toml +76 -0
- fastapifromfrictionless-0.1.0/setup.cfg +4 -0
- fastapifromfrictionless-0.1.0/tests/test_app_generator.py +289 -0
- fastapifromfrictionless-0.1.0/tests/test_cli.py +121 -0
- fastapifromfrictionless-0.1.0/tests/test_database_generator.py +52 -0
- fastapifromfrictionless-0.1.0/tests/test_dump_to_excel.py +115 -0
- fastapifromfrictionless-0.1.0/tests/test_logging_config.py +59 -0
- fastapifromfrictionless-0.1.0/tests/test_models_generator.py +208 -0
- fastapifromfrictionless-0.1.0/tests/test_validate.py +212 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jordan Inskeep
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapifromfrictionless
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Creating FastAPIs from Frictionless Data Packages
|
|
5
|
+
Author-email: MORPC data team <dataandmaps@morpc.org>, Jordan Inskeep <jinskeep@morpc.org>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: pandas
|
|
15
|
+
Requires-Dist: frictionless
|
|
16
|
+
Requires-Dist: SQLmodel
|
|
17
|
+
Requires-Dist: FastAPI
|
|
18
|
+
Requires-Dist: fastapi_querybuilder
|
|
19
|
+
Requires-Dist: sqlalchemy
|
|
20
|
+
Requires-Dist: xlsxwriter
|
|
21
|
+
Requires-Dist: jinja2
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# fastapi-from-frictionless
|
|
29
|
+
|
|
30
|
+
> **Status: Work in Progress** — API and generated output are subject to change.
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
`fastapifromfrictionless` is a Python scaffolding tool that reads [Frictionless Data Package](https://datapackage.org/standard/data-package/) schema files and generates a fully-functional [FastAPI](https://fastapi.tiangolo.com/) + [SQLModel](https://sqlmodel.tiangolo.com/) application — including models, CRUD endpoints, and dynamic query support — with no hand-written boilerplate.
|
|
35
|
+
|
|
36
|
+
The driving goal is to bridge the gap between familiar flat-file workflows (Excel workbooks, CSV files, Frictionless packages) and a production-grade relational database with a queryable REST API. Data stewards continue working in Excel; the package handles ingestion, validation, and API synchronization behind the scenes.
|
|
37
|
+
|
|
38
|
+
**Core capabilities:**
|
|
39
|
+
|
|
40
|
+
- Generate `models.py`, `app.py`, and `database.py` from `*.schema.yaml` files
|
|
41
|
+
- Automatic SQLModel class hierarchy per schema (base, table, create, update, public, public-with-relations)
|
|
42
|
+
- Full CRUD + pagination + recent-records endpoints per resource
|
|
43
|
+
- Excel workbook as a data-entry interface — create or update API records from a `.xlsx` file
|
|
44
|
+
- Frictionless package wraps the workbook for field-level validation before ingestion
|
|
45
|
+
- CLI entry point: `fastapifromfrictionless generate <schema-folder>`
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
- Python >= 3.10
|
|
50
|
+
- [frictionless](https://pypi.org/project/frictionless/)
|
|
51
|
+
- [FastAPI](https://pypi.org/project/fastapi/)
|
|
52
|
+
- [SQLModel](https://pypi.org/project/sqlmodel/)
|
|
53
|
+
- [SQLAlchemy](https://pypi.org/project/sqlalchemy/)
|
|
54
|
+
- [fastapi-querybuilder](https://github.com/bhadri01/fastapi-querybuilder)
|
|
55
|
+
- [jinja2](https://pypi.org/project/Jinja2/)
|
|
56
|
+
- [requests](https://pypi.org/project/requests/)
|
|
57
|
+
- [pandas](https://pypi.org/project/pandas/)
|
|
58
|
+
- [xlsxwriter](https://pypi.org/project/XlsxWriter/)
|
|
59
|
+
|
|
60
|
+
An ASGI server such as [uvicorn](https://www.uvicorn.org/) is required to run the generated application.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -e .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
### 1. Generate application files from schemas
|
|
71
|
+
|
|
72
|
+
Place `*.schema.yaml` files in a folder (see `doc/data/` for examples), then run:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
fastapifromfrictionless generate path/to/schemas --output path/to/output
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Or from Python:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from fastapifromfrictionless.load import build_database
|
|
82
|
+
|
|
83
|
+
build_database(schema_folder="path/to/schemas", db_filename="app.db")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Start the generated API
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd path/to/output
|
|
90
|
+
uvicorn app:app --reload
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. Generated endpoints
|
|
94
|
+
|
|
95
|
+
For each schema resource (e.g. `sensor`), the generated app exposes:
|
|
96
|
+
|
|
97
|
+
| Method | Path | Description |
|
|
98
|
+
|--------|------|-------------|
|
|
99
|
+
| `POST` | `/sensor` | Create a record |
|
|
100
|
+
| `GET` | `/sensor/all` | List all (paginated: `?offset=0&limit=100`) |
|
|
101
|
+
| `GET` | `/sensor/recent` | Most recent records (`?limit=10`) |
|
|
102
|
+
| `GET` | `/sensor/{id}` | Get one by primary key |
|
|
103
|
+
| `PATCH` | `/sensor/{id}` | Update a record |
|
|
104
|
+
| `DELETE` | `/sensor/{id}` | Delete a record |
|
|
105
|
+
| `GET` | `/sensor/query` | Dynamic filter query (FK schemas only) |
|
|
106
|
+
| `GET` | `/excel/export` | Download all data as `.xlsx` |
|
|
107
|
+
| `POST` | `/excel/import` | Upload and sync an `.xlsx` workbook |
|
|
108
|
+
|
|
109
|
+
### 4. Configuration via environment variables
|
|
110
|
+
|
|
111
|
+
| Variable | Default | Description |
|
|
112
|
+
|----------|---------|-------------|
|
|
113
|
+
| `DATABASE_URL` | `sqlite:///database.db` | Database connection URL (overrides SQLite default) |
|
|
114
|
+
| `ALLOWED_ORIGINS` | `*` | Comma-separated CORS allowed origins |
|
|
115
|
+
| `API_KEY` | *(unset)* | If set, all requests require `X-API-Key: <value>` header |
|
|
116
|
+
| `SCHEMA_FOLDER` | `.` | Path to `*.schema.yaml` files (used by Excel import/export) |
|
|
117
|
+
| `API_URL` | `http://localhost:8000` | Base URL of this app (used by Excel export) |
|
|
118
|
+
|
|
119
|
+
### 5. Excel data workflow
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from fastapifromfrictionless.load import empty_excel, create_package, update_api_from_package
|
|
123
|
+
|
|
124
|
+
# Create a blank workbook with one sheet per schema
|
|
125
|
+
empty_excel(schema_folder="path/to/schemas", output_filepath="data.xlsx")
|
|
126
|
+
|
|
127
|
+
# Fill in data, then validate and sync to the API
|
|
128
|
+
create_package(folder="path/to/schemas", filename="data.xlsx")
|
|
129
|
+
update_api_from_package(api_url="http://localhost:8000", package_file="data.package.yaml")
|
|
130
|
+
|
|
131
|
+
# Or export all current API data to Excel
|
|
132
|
+
from fastapifromfrictionless.load import dump_to_excel
|
|
133
|
+
dump_to_excel(api_url="http://localhost:8000", schema_folder="path/to/schemas", output_filepath="export.xlsx")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 6. CLI reference
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
fastapifromfrictionless generate <schema_folder> [options]
|
|
140
|
+
|
|
141
|
+
Options:
|
|
142
|
+
--output DIR Output directory (default: current directory)
|
|
143
|
+
--db FILENAME SQLite database filename (default: database.db)
|
|
144
|
+
--dry-run Print generated code to stdout without writing files
|
|
145
|
+
--no-models Skip generating models.py
|
|
146
|
+
--no-app Skip generating app.py
|
|
147
|
+
--no-db Skip generating database.py
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
See `doc/` for a worked example with real schemas and generated output.
|
|
151
|
+
|
|
152
|
+
## Roadmap
|
|
153
|
+
|
|
154
|
+
Items are grouped by priority. Checked items are complete.
|
|
155
|
+
|
|
156
|
+
### Foundation
|
|
157
|
+
|
|
158
|
+
- [x] Generate SQLModel class hierarchies from Frictionless schemas
|
|
159
|
+
- [x] Generate FastAPI CRUD + query endpoints per resource
|
|
160
|
+
- [x] Generate `database.py` with SQLite engine setup
|
|
161
|
+
- [x] Excel workbook as data-entry interface (create and update)
|
|
162
|
+
- [x] Frictionless package wrapping for field-level validation
|
|
163
|
+
- [x] Export API data back to Excel (dump all records to workbook)
|
|
164
|
+
- [x] Validate schemas before code generation; surface clear error messages on malformed input
|
|
165
|
+
|
|
166
|
+
### Code Quality & Reliability
|
|
167
|
+
|
|
168
|
+
- [x] Add a test suite (unit tests for generators, integration tests for generated app)
|
|
169
|
+
- [x] Add CI pipeline (lint, type-check, tests on push)
|
|
170
|
+
- [x] Enforce type hints throughout; run `mypy` in CI
|
|
171
|
+
- [x] Replace raw string generation with a templating engine (e.g. Jinja2) for maintainability
|
|
172
|
+
- [x] Structured logging with configurable verbosity
|
|
173
|
+
|
|
174
|
+
### Production Readiness
|
|
175
|
+
|
|
176
|
+
- [ ] Async database support (replace sync SQLModel sessions with async SQLAlchemy)
|
|
177
|
+
- [ ] Database migrations via [Alembic](https://alembic.sqlalchemy.org/) instead of `create_all`
|
|
178
|
+
- [x] Configuration management — accept settings via environment variables or a config file (database URL, allowed origins, etc.)
|
|
179
|
+
- [x] CORS and security headers in generated `app.py`
|
|
180
|
+
- [x] API key / token authentication ([FastAPI security](https://fastapi.tiangolo.com/tutorial/security/first-steps/))
|
|
181
|
+
- [x] Pagination on list endpoints
|
|
182
|
+
- [x] Proper HTTP error responses with consistent JSON error bodies
|
|
183
|
+
|
|
184
|
+
### Developer Experience
|
|
185
|
+
|
|
186
|
+
- [x] CLI entry point (`fastapifromfrictionless generate <schema-folder>`) so users do not need to write Python
|
|
187
|
+
- [x] Dry-run / preview mode that prints generated code without writing files
|
|
188
|
+
- [x] Configurable output — opt in/out of specific endpoint types, choose database backend
|
|
189
|
+
- [x] Package versioning and automated releases (GitHub Actions → PyPI)
|
|
190
|
+
- [x] Expand documentation and examples in `doc/`
|
|
191
|
+
|
|
192
|
+
### Optional / Future
|
|
193
|
+
|
|
194
|
+
- [x] Support for PostgreSQL and other SQLAlchemy-compatible backends
|
|
195
|
+
- [ ] Auto-generated front-end form from schema fields
|
|
196
|
+
- [ ] DrawIO ERD → Frictionless schema converter
|
|
197
|
+
- [x] Default query routes for common patterns derived from schema metadata
|
|
198
|
+
- [x] GET/POST file endpoints for uploading and downloading the Excel workbook directly via the API
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# fastapi-from-frictionless
|
|
2
|
+
|
|
3
|
+
> **Status: Work in Progress** — API and generated output are subject to change.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`fastapifromfrictionless` is a Python scaffolding tool that reads [Frictionless Data Package](https://datapackage.org/standard/data-package/) schema files and generates a fully-functional [FastAPI](https://fastapi.tiangolo.com/) + [SQLModel](https://sqlmodel.tiangolo.com/) application — including models, CRUD endpoints, and dynamic query support — with no hand-written boilerplate.
|
|
8
|
+
|
|
9
|
+
The driving goal is to bridge the gap between familiar flat-file workflows (Excel workbooks, CSV files, Frictionless packages) and a production-grade relational database with a queryable REST API. Data stewards continue working in Excel; the package handles ingestion, validation, and API synchronization behind the scenes.
|
|
10
|
+
|
|
11
|
+
**Core capabilities:**
|
|
12
|
+
|
|
13
|
+
- Generate `models.py`, `app.py`, and `database.py` from `*.schema.yaml` files
|
|
14
|
+
- Automatic SQLModel class hierarchy per schema (base, table, create, update, public, public-with-relations)
|
|
15
|
+
- Full CRUD + pagination + recent-records endpoints per resource
|
|
16
|
+
- Excel workbook as a data-entry interface — create or update API records from a `.xlsx` file
|
|
17
|
+
- Frictionless package wraps the workbook for field-level validation before ingestion
|
|
18
|
+
- CLI entry point: `fastapifromfrictionless generate <schema-folder>`
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Python >= 3.10
|
|
23
|
+
- [frictionless](https://pypi.org/project/frictionless/)
|
|
24
|
+
- [FastAPI](https://pypi.org/project/fastapi/)
|
|
25
|
+
- [SQLModel](https://pypi.org/project/sqlmodel/)
|
|
26
|
+
- [SQLAlchemy](https://pypi.org/project/sqlalchemy/)
|
|
27
|
+
- [fastapi-querybuilder](https://github.com/bhadri01/fastapi-querybuilder)
|
|
28
|
+
- [jinja2](https://pypi.org/project/Jinja2/)
|
|
29
|
+
- [requests](https://pypi.org/project/requests/)
|
|
30
|
+
- [pandas](https://pypi.org/project/pandas/)
|
|
31
|
+
- [xlsxwriter](https://pypi.org/project/XlsxWriter/)
|
|
32
|
+
|
|
33
|
+
An ASGI server such as [uvicorn](https://www.uvicorn.org/) is required to run the generated application.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install -e .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### 1. Generate application files from schemas
|
|
44
|
+
|
|
45
|
+
Place `*.schema.yaml` files in a folder (see `doc/data/` for examples), then run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
fastapifromfrictionless generate path/to/schemas --output path/to/output
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or from Python:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from fastapifromfrictionless.load import build_database
|
|
55
|
+
|
|
56
|
+
build_database(schema_folder="path/to/schemas", db_filename="app.db")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. Start the generated API
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd path/to/output
|
|
63
|
+
uvicorn app:app --reload
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Generated endpoints
|
|
67
|
+
|
|
68
|
+
For each schema resource (e.g. `sensor`), the generated app exposes:
|
|
69
|
+
|
|
70
|
+
| Method | Path | Description |
|
|
71
|
+
|--------|------|-------------|
|
|
72
|
+
| `POST` | `/sensor` | Create a record |
|
|
73
|
+
| `GET` | `/sensor/all` | List all (paginated: `?offset=0&limit=100`) |
|
|
74
|
+
| `GET` | `/sensor/recent` | Most recent records (`?limit=10`) |
|
|
75
|
+
| `GET` | `/sensor/{id}` | Get one by primary key |
|
|
76
|
+
| `PATCH` | `/sensor/{id}` | Update a record |
|
|
77
|
+
| `DELETE` | `/sensor/{id}` | Delete a record |
|
|
78
|
+
| `GET` | `/sensor/query` | Dynamic filter query (FK schemas only) |
|
|
79
|
+
| `GET` | `/excel/export` | Download all data as `.xlsx` |
|
|
80
|
+
| `POST` | `/excel/import` | Upload and sync an `.xlsx` workbook |
|
|
81
|
+
|
|
82
|
+
### 4. Configuration via environment variables
|
|
83
|
+
|
|
84
|
+
| Variable | Default | Description |
|
|
85
|
+
|----------|---------|-------------|
|
|
86
|
+
| `DATABASE_URL` | `sqlite:///database.db` | Database connection URL (overrides SQLite default) |
|
|
87
|
+
| `ALLOWED_ORIGINS` | `*` | Comma-separated CORS allowed origins |
|
|
88
|
+
| `API_KEY` | *(unset)* | If set, all requests require `X-API-Key: <value>` header |
|
|
89
|
+
| `SCHEMA_FOLDER` | `.` | Path to `*.schema.yaml` files (used by Excel import/export) |
|
|
90
|
+
| `API_URL` | `http://localhost:8000` | Base URL of this app (used by Excel export) |
|
|
91
|
+
|
|
92
|
+
### 5. Excel data workflow
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from fastapifromfrictionless.load import empty_excel, create_package, update_api_from_package
|
|
96
|
+
|
|
97
|
+
# Create a blank workbook with one sheet per schema
|
|
98
|
+
empty_excel(schema_folder="path/to/schemas", output_filepath="data.xlsx")
|
|
99
|
+
|
|
100
|
+
# Fill in data, then validate and sync to the API
|
|
101
|
+
create_package(folder="path/to/schemas", filename="data.xlsx")
|
|
102
|
+
update_api_from_package(api_url="http://localhost:8000", package_file="data.package.yaml")
|
|
103
|
+
|
|
104
|
+
# Or export all current API data to Excel
|
|
105
|
+
from fastapifromfrictionless.load import dump_to_excel
|
|
106
|
+
dump_to_excel(api_url="http://localhost:8000", schema_folder="path/to/schemas", output_filepath="export.xlsx")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 6. CLI reference
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
fastapifromfrictionless generate <schema_folder> [options]
|
|
113
|
+
|
|
114
|
+
Options:
|
|
115
|
+
--output DIR Output directory (default: current directory)
|
|
116
|
+
--db FILENAME SQLite database filename (default: database.db)
|
|
117
|
+
--dry-run Print generated code to stdout without writing files
|
|
118
|
+
--no-models Skip generating models.py
|
|
119
|
+
--no-app Skip generating app.py
|
|
120
|
+
--no-db Skip generating database.py
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See `doc/` for a worked example with real schemas and generated output.
|
|
124
|
+
|
|
125
|
+
## Roadmap
|
|
126
|
+
|
|
127
|
+
Items are grouped by priority. Checked items are complete.
|
|
128
|
+
|
|
129
|
+
### Foundation
|
|
130
|
+
|
|
131
|
+
- [x] Generate SQLModel class hierarchies from Frictionless schemas
|
|
132
|
+
- [x] Generate FastAPI CRUD + query endpoints per resource
|
|
133
|
+
- [x] Generate `database.py` with SQLite engine setup
|
|
134
|
+
- [x] Excel workbook as data-entry interface (create and update)
|
|
135
|
+
- [x] Frictionless package wrapping for field-level validation
|
|
136
|
+
- [x] Export API data back to Excel (dump all records to workbook)
|
|
137
|
+
- [x] Validate schemas before code generation; surface clear error messages on malformed input
|
|
138
|
+
|
|
139
|
+
### Code Quality & Reliability
|
|
140
|
+
|
|
141
|
+
- [x] Add a test suite (unit tests for generators, integration tests for generated app)
|
|
142
|
+
- [x] Add CI pipeline (lint, type-check, tests on push)
|
|
143
|
+
- [x] Enforce type hints throughout; run `mypy` in CI
|
|
144
|
+
- [x] Replace raw string generation with a templating engine (e.g. Jinja2) for maintainability
|
|
145
|
+
- [x] Structured logging with configurable verbosity
|
|
146
|
+
|
|
147
|
+
### Production Readiness
|
|
148
|
+
|
|
149
|
+
- [ ] Async database support (replace sync SQLModel sessions with async SQLAlchemy)
|
|
150
|
+
- [ ] Database migrations via [Alembic](https://alembic.sqlalchemy.org/) instead of `create_all`
|
|
151
|
+
- [x] Configuration management — accept settings via environment variables or a config file (database URL, allowed origins, etc.)
|
|
152
|
+
- [x] CORS and security headers in generated `app.py`
|
|
153
|
+
- [x] API key / token authentication ([FastAPI security](https://fastapi.tiangolo.com/tutorial/security/first-steps/))
|
|
154
|
+
- [x] Pagination on list endpoints
|
|
155
|
+
- [x] Proper HTTP error responses with consistent JSON error bodies
|
|
156
|
+
|
|
157
|
+
### Developer Experience
|
|
158
|
+
|
|
159
|
+
- [x] CLI entry point (`fastapifromfrictionless generate <schema-folder>`) so users do not need to write Python
|
|
160
|
+
- [x] Dry-run / preview mode that prints generated code without writing files
|
|
161
|
+
- [x] Configurable output — opt in/out of specific endpoint types, choose database backend
|
|
162
|
+
- [x] Package versioning and automated releases (GitHub Actions → PyPI)
|
|
163
|
+
- [x] Expand documentation and examples in `doc/`
|
|
164
|
+
|
|
165
|
+
### Optional / Future
|
|
166
|
+
|
|
167
|
+
- [x] Support for PostgreSQL and other SQLAlchemy-compatible backends
|
|
168
|
+
- [ ] Auto-generated front-end form from schema fields
|
|
169
|
+
- [ ] DrawIO ERD → Frictionless schema converter
|
|
170
|
+
- [x] Default query routes for common patterns derived from schema metadata
|
|
171
|
+
- [x] GET/POST file endpoints for uploading and downloading the Excel workbook directly via the API
|
|
File without changes
|