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.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bootstrapi-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9c352cebe8771729112e9b29bf48a48e34a512e32da6b43b7a55575b67681c07
MD5 009d574ce2864175b368805fd0923d7b
BLAKE2b-256 8643b468624c0691dda6681f2c5d5e1ef92c6b17f3be4b9e539f5fa2eac37024

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bootstrapi-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7686e8d30b39834e72ed8b45e6c3872cbbd572848e8c1c13f0ecac4cb29daac9
MD5 ca3a79c50b349e06f5c6567017f8b2be
BLAKE2b-256 6b7d7d975996b0d47c4e66b34102cd7ff02686842690143d89ec58d8b3680aea

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