Skip to main content

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.
  • 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.

NOTE: At this time OR operator are not implemented

Use fields parameter to get only the fields listes as value, separated by ;.

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.

Configuration

  1. AUTOCRUD_METADATA_ENABLED: (default: True) enable metadata endpoint for a resource: <endpoint>/<resource>/meta

  2. AUTOCRUD_READ_ONLY: (default: False) enable only http GET method

  3. AUTOCRUD_BASE_URL: (default: ‘/’) prefix url for resources

  4. AUTOCRUD_SUBDOMAIN: (default: None) bind autocrud endpoints to a subdomain

License MIT

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-AutoCRUD-1.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

Flask_AutoCRUD-1.1.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file Flask-AutoCRUD-1.1.2.tar.gz.

File metadata

  • Download URL: Flask-AutoCRUD-1.1.2.tar.gz
  • Upload date:
  • Size: 7.3 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

Hashes for Flask-AutoCRUD-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4c02c2d7e73f44e9c86cc7215d8b6a4a93645e4d15f57cbb2c29276f251c2b6f
MD5 5ff8926a275f23e68ba961b63e688e7d
BLAKE2b-256 4d4eb7104f8f120b9dfefac454cb0f46b7c81ed65e1ae4d51ec7146b4cb6973a

See more details on using hashes here.

File details

Details for the file Flask_AutoCRUD-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: Flask_AutoCRUD-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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

Hashes for Flask_AutoCRUD-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 80cb09c156a03f14dea678ab5c7af5279e13456fbc69ab53ada939bb1cf23457
MD5 daa07cb3cb904493c89f0ab49c893e21
BLAKE2b-256 71c5ac5e5584c2bd600a493e63a5042ad3e36a9f4f0523bebd6128d900a0577a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page