Skip to main content

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


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 details)

Uploaded Source

Built Distribution

bootstrapi-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file bootstrapi-0.1.0.tar.gz.

File metadata

  • Download URL: bootstrapi-0.1.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for bootstrapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 444bb236e978c9cab0d4cb7ba58b6e66f8631bc7661c5d29251569c695f253d3
MD5 60b257a44b4aad5b314883967ade032b
BLAKE2b-256 4a46ab01757e3d7ec390ed45c530f2097777fbc6e6765bee3f598dac6b8b1a59

See more details on using hashes here.

File details

Details for the file bootstrapi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bootstrapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for bootstrapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 211fa0f0af518e1737e1013ab565c8cac5f70011edb0cae2ded989a186e65995
MD5 d099fcd9f7991e2a9a9ed46f5362de5e
BLAKE2b-256 924a8bae4cfc416968592f88ee9c2a90f8a9f6304df0277460bbf8463071b21f

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