msaCRUD - SQLModel/SQLAlchemy/FastAPI - DB Object CRUD/API Automation
Project description
msaCRUD - SQLModel/SQLAlchemy/FastAPI - DB Object CRUD/API Automation
Optimized for use with FastAPI/Pydantic. Generates CRUD Router based on SQLModel and SQLAlchemy.
Documentation: msaCRUD Documentation (https://msaCRUD.u2d.ai/)
Main Dependencies
- fastapi[all]~=0.85.0 # FastAPI framework, high performance, easy to learn, fast to code, ready for production
- starlette~=0.20.4 # Starlette is a lightweight ASGI framework/toolkit, which is ideal for building async web services in Python.
- sqlmodel~=0.0.8 # SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.
- sqlalchemy[asyncio]~=1.4.41 # Database Abstraction Library
- sqlalchemy_database~=0.0.7 # SQLAlchemy-Database provides shortcut functions to common database operations for SQLAlchemy ORM
Usage
from typing import Optional, List
from sqlmodel import SQLModel, Field
from fastapi import FastAPI
from msaCRUD import MSASQLModelCrud
class TestArticle(SQLModel, table=True):
__table_args__ = {'extend_existing': True}
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
content: str = Field(title='ArticleContent')
class TestCategory(SQLModel, table=True):
__table_args__ = {'extend_existing': True}
id: Optional[int] = Field(default=None, primary_key=True, nullable=False)
title: str = Field(title='ArticleTitle', max_length=200)
description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400)
status: bool = Field(None, title='status')
content: str = Field(title='ArticleContent')
app = FastAPI()
# create your preferred DB Engine, create the schemas and then you can create the CRUD API models and add the router
# if you like
new_crud: MSASQLModelCrud = MSASQLModelCrud(model=TestArticle, engine=YOUR_DB_ENGINE).register_crud()
app.include_router(new_crud.router)
new_crud_second: MSASQLModelCrud = MSASQLModelCrud(model=TestCategory, engine=YOUR_DB_ENGINE).register_crud()
app.include_router(new_crud_second.router)
if __name__ == '__main__':
pass
License Agreement
msaCRUD
Based onMIT
open source and free to use, it is free for commercial use, but please show/list the copyright information about msaCRUD somewhere.
How to create the documentation
We use mkdocs and mkdocsstring. The code reference and nav entry get's created virtually by the triggered python script /docs/gen_ref_pages.py while mkdocs
serve
or build
is executed.
Requirements Install for the PDF creation option:
PDF Export is using mainly weasyprint, if you get some errors here pls. check there documentation. Installation is part of the msaCRUD, so this should be fine.
We can now test and view our documentation using:
mkdocs serve
Build static Site:
mkdocs build
Build and Publish
Build:
python setup.py sdist
Publish to pypi:
twine upload dist/*
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
File details
Details for the file msaCRUD-0.0.1.tar.gz
.
File metadata
- Download URL: msaCRUD-0.0.1.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd615bd93b0c028c63973a038e508fb41103028149661b509f2278c7e5196cfc |
|
MD5 | af83b78bfe329bf8ca3e43dfaeadcd67 |
|
BLAKE2b-256 | 921209486090c0e399f5679ec4ce9f7ccf0d6ff71823280bd6e61f342c3db500 |