A tool to export model schemas from Django, SQLAlchemy, and FastAPI to JSON
Project description
Model Schema Exporter
Model Schema Exporter is a versatile Python tool that extracts model schemas from Django, SQLAlchemy, and FastAPI applications and exports them to JSON format. This tool is particularly useful for developers who need to visualize their data models or integrate them with other tools.
Installation
You can install Model Schema Exporter using pip:
pip install model-schema-exporter
Usage
Model Schema Exporter can be used as a command-line tool:
model-schema-exporter <framework> <app_module> <output_file>
<framework>
: The web framework you're using. Choose from 'django', 'sqlalchemy', or 'fastapi'.<app_module>
: The Python module containing your models.<output_file>
: The path where the output JSON file will be saved.
Options
--pretty
: Output pretty-printed JSON for better readability.
Examples
- For a Django project:
model-schema-exporter django myproject.myapp.models output.json
- For a SQLAlchemy project:
model-schema-exporter sqlalchemy myproject.models output.json
- For a FastAPI project using Pydantic models:
model-schema-exporter fastapi myproject.models output.json
Output Format
The tool generates a JSON file with the following structure:
{
"models": [
{
"name": "ModelName",
"fields": [
{
"name": "field_name",
"type": "FieldType",
"nullable": true,
"unique": false
}
// ... more fields
]
}
// ... more models
]
}
Framework-specific Notes
Django
- Ensure your Django settings are properly configured.
- The tool will automatically discover all models in your Django project.
SQLAlchemy
- Make sure your models are defined using the declarative base.
- The tool will find all classes that inherit from the SQLAlchemy declarative base.
FastAPI
- Your Pydantic models should be importable from the specified module.
- The tool will extract all classes that inherit from
pydantic.BaseModel
.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
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
File details
Details for the file model-schema-exporter-0.1.1.tar.gz
.
File metadata
- Download URL: model-schema-exporter-0.1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.19 tqdm/4.64.1 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebe065e7f808122f2cc5b4ea712dd434dc86ad8547543800fe2d62558a3c3f82 |
|
MD5 | 1f2be903cc225c1b98f9437366dc146b |
|
BLAKE2b-256 | 3237e4d7ea429314ab9ec747ff52a527a5020ba74463412c1c68cc458d2e704d |
File details
Details for the file model_schema_exporter-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: model_schema_exporter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.19 tqdm/4.64.1 importlib-metadata/4.2.0 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd2f79e75e902fbdd8c155a80f1919e889726b740dd696293ab03dd3bad947df |
|
MD5 | a709a5cc584e2da0e96d3d89b6e2b9d1 |
|
BLAKE2b-256 | 65672e01fbdc218b09a4ff048c2745b1a8d3bb31d2460ea56ab725fcbfe2a263 |