Automatically generate a RESTful API service for CRUD operation on database
Project description
Based on sandman2.
Automatically generate a RESTful API service for CRUD operation on database. If a list of tables or a list of sqlalchemy model is not provided, all tables are affected.
For api documentation see sandman2 documentation
Quickstart
Install flask_autocrud using pip:
$ pip install Flask-AutoCRUD
Example usage
from flask import Flask
from flask_autocrud import AutoCrud
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite+pysqlite:///db.sqlite3'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['AUTOCRUD_METADATA_ENABLED'] = True
db = SQLAlchemy(app)
AutoCrud(app, db)
app.run(debug=True)
Go to http://127.0.0.1:5000/ and see all available resources with its endpoint. NOTE: you must set SQLALCHEMY_DATABASE_URI with your database.
If you want to see an example use with Flask-Admin see in example folder.
Filtering and Sorting
Add filters as query string parameters, they are used in AND. NOTE: At this time OR operator are not implemented.
You can use entity fields as parameter with the following placeholders:
null value: null
in operator: list separated by ;
not operator: ! means: not equal, not null, not in
like operator: % for example: %%test%, %test% or %%test. NOTE first % are not used in expression, it only indicated that value must be used with like operator.
Other parameters:
Use fields parameter to get only the fields listes as value, separated by ;.
Use limit and page parameters for pagination.
Use export parameter to export data into csv format.
Sorting is implemented with sort parameter. The value is a list of field separated by ; You can prepend - to reverse order.
Example requests:
http://127.0.0.1:5000/invoice?fields=Total;InvoiceId&BillingPostalCode=!null&BillingCountry=%%ermany
http://127.0.0.1:5000/invoice?fields=Total;InvoiceDate;InvoiceId;CustomerId&page=2&limit=10
Configuration
AUTOCRUD_METADATA_ENABLED: (default: True) enable metadata endpoint for a resource: <endpoint>/<resource>/meta
AUTOCRUD_READ_ONLY: (default: False) enable only http GET method
AUTOCRUD_BASE_URL: (default: ‘/’) prefix url for resources
AUTOCRUD_SUBDOMAIN: (default: None) bind autocrud endpoints to a subdomain
License MIT
Project details
Release history Release notifications | RSS feed
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 Flask-AutoCRUD-1.1.3.tar.gz
.
File metadata
- Download URL: Flask-AutoCRUD-1.1.3.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73b343b92a6eeebbc2008cadf79ae1490cbe9c130e3404c6c0b28242d155b184 |
|
MD5 | a5bbe0f2828c1a786b9cbc176dc97e23 |
|
BLAKE2b-256 | 799a3c8cb06728791e68f6efc2a38f58649cdb13ddf524301b051d8e12056e72 |
File details
Details for the file Flask_AutoCRUD-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: Flask_AutoCRUD-1.1.3-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0edd3f12b3b93b33e3a2dbdf832da41e01b83b9931dd82f653e63efd715c8d7e |
|
MD5 | 7674be572a80c4e38433d289b964ceb8 |
|
BLAKE2b-256 | 1ccc7dc2898ac6fb4263a3bae5b31c13abb6fea90181c86a1c06404173426f1b |