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()
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
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 hashes)
Built Distribution
apidb-0.2.1-py3-none-any.whl
(5.4 kB
view hashes)