Generate an API from an existing database automatically. Includes OpenAPI docs and OData like queries.
Project description
BootstrAPI
Automatically generate an OpenAPI for your existing database.
Features
- Generates an API for your current database
- Generates OpenAPI docs
- Supports OData-like queries ($select, $filter, $expand)
- Support all RESTful HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Supports all Databases supported by SQLAlchemy
Requirements
Python
- Python 3.6+
Database
- Exactly one primary key per table
Quickstart
There are 3 main ways to run the code. As a standalone Python app, as a package and a Docker container.
Python App
First clone the code into a folder, then run:
$ pip install -r requirements.txt
$ python -m run connection_string [--title "API"] [--host 0.0.0.0] [--port 8000] [--schema dbo]
Python Package
Install the bootstrapi package
$ pip install bootstrapi
Then create an FastAPI app and register the routes.
import uvicorn
from fastapi.applications import FastAPI
from sqlalchemy import create_engine
from sqlalchemy.ext.automap import automap_base
from bootstrapi.router import BootstrAPIRouter
connection_string = "" #Your SQLAlchemy Connection string here
engine = create_engine(connection_string)
app = FastAPI(title='My API')
Base = automap_base()
Base.prepare(engine,schema = schema)
router = BootstrAPIRouter(engine,Base)
app.include_router(router)
uvicorn.run(app, host='127.0.0.1', port=8000)
Docker
$ docker run --env connection="YOUR_CONNECTION_STRING" -p 8000:8000 mrpowerus/bootstrapi
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
bootstrapi-0.1.0.tar.gz
(20.1 kB
view hashes)
Built Distribution
bootstrapi-0.1.0-py3-none-any.whl
(20.3 kB
view hashes)
Close
Hashes for bootstrapi-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 211fa0f0af518e1737e1013ab565c8cac5f70011edb0cae2ded989a186e65995 |
|
MD5 | d099fcd9f7991e2a9a9ed46f5362de5e |
|
BLAKE2b-256 | 924a8bae4cfc416968592f88ee9c2a90f8a9f6304df0277460bbf8463071b21f |