tortoise-api


Nametortoise-api JSON
Version 0.10.12 PyPI version JSON
download
home_pageNone
SummarySimplest fastest minimal REST API CRUD generator for Tortoise ORM models
upload_time2024-09-24 22:04:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords starlette fastapi admin generator db-model crud tortoise-orm asgi-admin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tortoise-API
###### Simplest fastest minimal REST API CRUD generator for Tortoise ORM models.
Fully async Zero config One line ASGI app

#### Requirements
- Python >= 3.10

### INSTALL
```bash
pip install tortoise-api
```

### Run your app
- Describe your db models with Tortoise ORM in `models.py` module
```python
from tortoise_api import Model

class User(Model):
    id: int = fields.IntField(pk=True)
    name: str = fields.CharField(255, unique=True, null=False)
    posts: fields.ReverseRelation["Post"]

class Post(Model):
    id: int = fields.IntField(pk=True)
    text: str = fields.CharField(4095)
    user: User = fields.ForeignKeyField('models.User', related_name='posts')
    _name = 'text' # `_name` sets the attr for displaying related Post instace inside User (default='name')
```
- Write run script `main.py`: pass your models module in Api app:
```python
from tortoise_api import Api
import models

app = Api().start(models)
```
- Set `DB_URL` env variable in `.env` file
- Run it:
```bash
uvicorn main:app
```
Or you can just fork Completed minimal runnable example from [sample apps](https://github.com/mixartemev/tortoise-api/blob/master/sample_apps/minimal/).

#### And voila:
You have menu with all your models at root app route: http://127.0.0.1:8000

<img width="245" alt="Home - Models list" src="https://github.com/mixartemev/tortoise-api/assets/5181924/0ddaa015-2193-43e1-a6d1-2dbad09bfc7b">


And JSON resources for each db Entity at [/{modelName}]() routes:

<img width="450" alt="User JSON resources" src="https://github.com/mixartemev/tortoise-api/assets/5181924/d4497aa5-1f10-45f3-82e8-f5145b72572e">


And one separate Entity at [/{modelName}/{entity_id}]() routes:

<img width="362" alt="User 1 JSON resource" src="https://github.com/mixartemev/tortoise-api/assets/5181924/f1fed04c-8bf2-462c-ad71-fbee35652b1a">


---
Made with ❤ on top of the Starlette and Tortoise ORM.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tortoise-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "starlette, fastapi, admin, generator, db-model, crud, tortoise-orm, ASGI-admin",
    "author": null,
    "author_email": "Artemiev <mixartemev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/97/c2/19e718d0bec75740b122a6bdf221d0f1b163830da3342b1d2dfa9048ac29/tortoise_api-0.10.12.tar.gz",
    "platform": null,
    "description": "# Tortoise-API\n###### Simplest fastest minimal REST API CRUD generator for Tortoise ORM models.\nFully async Zero config One line ASGI app\n\n#### Requirements\n- Python >= 3.10\n\n### INSTALL\n```bash\npip install tortoise-api\n```\n\n### Run your app\n- Describe your db models with Tortoise ORM in `models.py` module\n```python\nfrom tortoise_api import Model\n\nclass User(Model):\n    id: int = fields.IntField(pk=True)\n    name: str = fields.CharField(255, unique=True, null=False)\n    posts: fields.ReverseRelation[\"Post\"]\n\nclass Post(Model):\n    id: int = fields.IntField(pk=True)\n    text: str = fields.CharField(4095)\n    user: User = fields.ForeignKeyField('models.User', related_name='posts')\n    _name = 'text' # `_name` sets the attr for displaying related Post instace inside User (default='name')\n```\n- Write run script `main.py`: pass your models module in Api app:\n```python\nfrom tortoise_api import Api\nimport models\n\napp = Api().start(models)\n```\n- Set `DB_URL` env variable in `.env` file\n- Run it:\n```bash\nuvicorn main:app\n```\nOr you can just fork Completed minimal runnable example from [sample apps](https://github.com/mixartemev/tortoise-api/blob/master/sample_apps/minimal/).\n\n#### And voila:\nYou have menu with all your models at root app route: http://127.0.0.1:8000\n\n<img width=\"245\" alt=\"Home - Models list\" src=\"https://github.com/mixartemev/tortoise-api/assets/5181924/0ddaa015-2193-43e1-a6d1-2dbad09bfc7b\">\n\n\nAnd JSON resources for each db Entity at [/{modelName}]() routes:\n\n<img width=\"450\" alt=\"User JSON resources\" src=\"https://github.com/mixartemev/tortoise-api/assets/5181924/d4497aa5-1f10-45f3-82e8-f5145b72572e\">\n\n\nAnd one separate Entity at [/{modelName}/{entity_id}]() routes:\n\n<img width=\"362\" alt=\"User 1 JSON resource\" src=\"https://github.com/mixartemev/tortoise-api/assets/5181924/f1fed04c-8bf2-462c-ad71-fbee35652b1a\">\n\n\n---\nMade with \u2764 on top of the Starlette and Tortoise ORM.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simplest fastest minimal REST API CRUD generator for Tortoise ORM models",
    "version": "0.10.12",
    "project_urls": {
        "Homepage": "https://github.com/mixartemev/x-api",
        "Repository": "https://github.com/mixartemev/x-api"
    },
    "split_keywords": [
        "starlette",
        " fastapi",
        " admin",
        " generator",
        " db-model",
        " crud",
        " tortoise-orm",
        " asgi-admin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47e8194e5715951df242edae5a08eeb276c75dd16d36c45bf236cd58f0a6fa38",
                "md5": "7bc204fa19207fddee9440e9c3adb6a4",
                "sha256": "3bb7f1c3e37bf26436fee5b0d911463e47bdcd51b3406389f726317563ab8676"
            },
            "downloads": -1,
            "filename": "tortoise_api-0.10.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7bc204fa19207fddee9440e9c3adb6a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 10041,
            "upload_time": "2024-09-24T22:04:49",
            "upload_time_iso_8601": "2024-09-24T22:04:49.790119Z",
            "url": "https://files.pythonhosted.org/packages/47/e8/194e5715951df242edae5a08eeb276c75dd16d36c45bf236cd58f0a6fa38/tortoise_api-0.10.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97c219e718d0bec75740b122a6bdf221d0f1b163830da3342b1d2dfa9048ac29",
                "md5": "e43e90791c2832a93883c7828c1fc015",
                "sha256": "1cd837989fcb9c5582542be13547f64a24b28f578edbb275af547e359a1859e6"
            },
            "downloads": -1,
            "filename": "tortoise_api-0.10.12.tar.gz",
            "has_sig": false,
            "md5_digest": "e43e90791c2832a93883c7828c1fc015",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 11895,
            "upload_time": "2024-09-24T22:04:51",
            "upload_time_iso_8601": "2024-09-24T22:04:51.377726Z",
            "url": "https://files.pythonhosted.org/packages/97/c2/19e718d0bec75740b122a6bdf221d0f1b163830da3342b1d2dfa9048ac29/tortoise_api-0.10.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 22:04:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mixartemev",
    "github_project": "x-api",
    "github_not_found": true,
    "lcname": "tortoise-api"
}
        
Elapsed time: 0.30882s