Flask-SQLA2api
Flask middleware that creates a simple Flask API CRUD REST endpoint based on a SQLAlchemy model definition.
Basic usage
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_sqla2api import SQLA2api
# Init app and DB
app = Flask(__name__)
db = SQLAlchemy(app)
# Setup a simple SQLAlchemy model
class Entry(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80))
# Init Flask-sqla2api
api = SQLA2api([Entry], self.db)
api.append_blueprints(app)
The previous tiny app will create the following endpoints
URL |
HTTP Method |
Action |
|---|---|---|
/entry |
GET |
Get all entries |
/entry |
POST |
Create new entry |
/entry/<id> |
GET |
Get a single entry |
/entry/<id> |
PUT |
Edit existing entry |
/entry/<id> |
DELETE |
Delete existing entry |
Generate single blueprint
If you want more control over your blueprints you can generate it and append it yourself to your app.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_sqla2api import generate_blueprint
# Init app and DB
app = Flask(__name__)
db = SQLAlchemy(app)
# Setup a simple SQLAlchemy model
class Entry(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80))
# Generate and register blueprint
blueprint = generate_blueprint(Entry, db)
app.register_blueprint(blueprint, url_endpoint='/')
To-Do
Input validation
API docs generation
Metadata
Release files for Flask-SQLA2api 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Flask-SQLA2api-0.2.1.tar.gz | 4.5 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_SQLA2api-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
| Flask_SQLA2api-0.2.1-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 18.3 kB
Release files / Flask-SQLA2api-0.2.1.tar.gz
| Download URL | Flask-SQLA2api-0.2.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
230e36447caaeddd6092a88a7fbeb268a6acaa3093cd7d30643d107fa5eed95f
|
|
BLAKE2b-256 checksum How to use checksums |
cdc6d31effab52b7eeacc46db93f1433f1a4e9eb091c173a0ad16268c8a86654
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_SQLA2api-0.2.1-py2.py3-none-any.whl
| Download URL | Flask_SQLA2api-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ea512d61ae94cadc530475228b2481fc0e356fc64ba9810e8474116d67bf0e8b
|
|
BLAKE2b-256 checksum How to use checksums |
d292123201727f3703cfbb290b123c649431b639b8975c522eca07d01c29b53b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_SQLA2api-0.2.1-py2.7.egg
| Download URL | Flask_SQLA2api-0.2.1-py2.7.egg |
|---|---|
| Size | 7.1 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
129ed8e5f0af63aa2493f9d8ea624e725a4973ea01a9f38ecea6c6c4465e4fc9
|
|
BLAKE2b-256 checksum How to use checksums |
bfca06180cc6c0c82e11baa121b6563d18ec2a7385340d0c25dc7934daa20aab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |