Flask extension for automatically generating RESTful APIs from SQLAlchemy models
Project description
flask-api-sqlalchemy
A Flask extension that automatically generates RESTful APIs from SQLAlchemy models.
Features
- Simple integration with existing Flask and SQLAlchemy applications
- Automatic discovery of SQLAlchemy models
- Automatic mapping of SQLAlchemy types to Flask-RESTX API model types
- Fully generated REST endpoints for all models
- Comprehensive test suite
- Modern Python packaging
Installation for Your Project
pip install flask-api-sqlalchemy
Installation for Development
pip install -e .
## Usage
```python
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy_api import Api
# Create Flask application
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
# Initialize SQLAlchemy
db = SQLAlchemy(app)
# Define your SQLAlchemy models
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
# Initialize the API extension
api = Api()
api.init_app(app, db)
if __name__ == '__main__':
app.run()
That's it! The extension automatically:
- Discovers all your SQLAlchemy models
- Creates appropriate Flask-RESTX models and serializers
- Generates full CRUD API endpoints for each model
- Provides Swagger documentation at
/api/docs
License
MIT
LICENSE
MIT License
Copyright (c) 2025 Sean McCarthy
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 flask_api_sqlalchemy-0.1.1.tar.gz.
File metadata
- Download URL: flask_api_sqlalchemy-0.1.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.6 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b4ce0ad66039bf6476a7027de12464bd21a6d0211791d5bd547649860a9b4d3
|
|
| MD5 |
f52c43f364f7c8b7658089adad0c3c9c
|
|
| BLAKE2b-256 |
02a913ac48d80559c6a6a548cdbf03b4def3dcd9e8236266b07ba0c8aad8cd3a
|
File details
Details for the file flask_api_sqlalchemy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flask_api_sqlalchemy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.6 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b225e96034be475c35ce4677e22900955e47c9c5f699417267d97ee6f867c4e9
|
|
| MD5 |
e0ba308d5d222e4db4240b0645c60283
|
|
| BLAKE2b-256 |
9d7262297700c2b3844d419a02ed405abae44c1aebc329aaa192ac7946d2f380
|