Skip to main content

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:

  1. Discovers all your SQLAlchemy models
  2. Creates appropriate Flask-RESTX models and serializers
  3. Generates full CRUD API endpoints for each model
  4. 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

flask_api_sqlalchemy-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

flask_api_sqlalchemy-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

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

Hashes for flask_api_sqlalchemy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b4ce0ad66039bf6476a7027de12464bd21a6d0211791d5bd547649860a9b4d3
MD5 f52c43f364f7c8b7658089adad0c3c9c
BLAKE2b-256 02a913ac48d80559c6a6a548cdbf03b4def3dcd9e8236266b07ba0c8aad8cd3a

See more details on using hashes here.

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

Hashes for flask_api_sqlalchemy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b225e96034be475c35ce4677e22900955e47c9c5f699417267d97ee6f867c4e9
MD5 e0ba308d5d222e4db4240b0645c60283
BLAKE2b-256 9d7262297700c2b3844d419a02ed405abae44c1aebc329aaa192ac7946d2f380

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