Simple Python ORM/ODM specifically designed to be used with Pydantic and FastAPI
Project description
odim
Simple Python ORM/ODM specifically designed to be used with Pydantic and FastAPI
Simple syntax
In order to nicely work with databases you just create your Pydantic models. Odim does not care if it is MongoDB or SQL.
from pydantic import BaseModel
class MyModel(BaseModel):
id : int
field : str
class Config:
db_uri = "mongodb://user:pwd@10.0.0.1/db1"
collection_name = "mymodel"
Then you can easily perform CRUD operations.
obj = MyModel(id=1, field="asdf 213")
await Odim(obj).save()
obj2 = await Odim(MyModel).get(123)
for x in await Odim(MyModel).find({"field" : "asdf 213"}):
print(x)
await Odim(MyModel).count({"field" : 1})
In case you are using amazin FastAPI. We have our extended router, that gives you CRUD API endpoint
from odim.router import OdimRouter
router = OdimRouter()
router.mount_crud("/api/mymodel/", model=MyModel, tags=["mymodel"])
Or you can generate these API stubs with
router.generate("/api/mymodel/", model=MyModel, tags=["mymodel"])
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
odim-0.1.33.tar.gz
(16.3 kB
view details)
Built Distribution
odim-0.1.33-py3-none-any.whl
(19.7 kB
view details)
File details
Details for the file odim-0.1.33.tar.gz
.
File metadata
- Download URL: odim-0.1.33.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 949a507aaf8422cffedc2f87b87fba8a930cefce2b6f85b215bcfcb931543b0c |
|
MD5 | bd449ca837960c0a4e14ba21c627dac5 |
|
BLAKE2b-256 | 186afa0a2cf1b0597286701c0b9022a6982d8ee0c5787bdf675ecf746130b9c0 |
File details
Details for the file odim-0.1.33-py3-none-any.whl
.
File metadata
- Download URL: odim-0.1.33-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2565c9039a0a56e96ae9272cb1fe9555cfd16865af810a5c639af70f6b08b7c7 |
|
MD5 | 0bacfbfdfc3986ad772c08d9fc55d8e4 |
|
BLAKE2b-256 | c4d1c05574a143463672ad88552f67d93134e9af6132da7e720680ceaa2e0a7e |