Skip to main content

Autogenerate API based on DB structure directly from Python using ORM

Project description

apidb

Autogenerate API based on DB structure directly from Python using ORM

Installation

Use the package manager pip to install apidb.

pip install apidb

Usage

from fastapi import FastAPI
import apidb.apidb_core as ad
import uvicorn

description = """
This is your API
"""

app = FastAPI(title="Example API",
    description=description,
    version="1.0.0",
    )

db_api_dict={'workspaces':'read','nodes':['read','create','update','delete']}
column_names=["workspace_name"]

ad.initialize_fastapi(app, db_api_dict, column_names, mysql)

@app.get("/api/v1/custom_workspaces")
def get_workspaces():
    """
    Returns all workspaces
    """
    return {"workspaces": []}

def run_api():
    uvicorn.run(app, host="0.0.0.0", port=8000)

if __name__=="__main__":
    run_api()

obrazek

Current scope

Aims: Easy generation of API in Fastapi + Flask based on structure in DB (current dialects: MySQL, PostgreSQL, SQL Server, Mongo) or on series of predefined functions

Done: Flask and FastAPI simple example

Todo: Generalization

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

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

apidb-0.2.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

apidb-0.2.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file apidb-0.2.1.tar.gz.

File metadata

  • Download URL: apidb-0.2.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for apidb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3cbdf83df1653a78b2a546f00e8586721d3e423f484e41ea3dbfbeec2d37f09e
MD5 3655bb1df9b2913b890210968a5fb83c
BLAKE2b-256 f7d9f37e3046b4485ea8729b5cf7c0fab4abc28ac532649ff81604dbfd8ef0ce

See more details on using hashes here.

File details

Details for the file apidb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: apidb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for apidb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 025c2aa1fb0447701e489ce7379edcacba8efc34b0ceca165c3f28d5d496a255
MD5 be24badd3506e1417654c69086232a34
BLAKE2b-256 f6bd61127fcdb054d7da1b02aaba1c1e9677c6c2157cad2318847ce44e7803b3

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