Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iloveitaly/activemodel
Make SQLModel more like an a real ORM
https://github.com/iloveitaly/activemodel
activemodel activerecord orm sqlalchemy sqlmodel
Last synced: about 2 months ago
JSON representation
Make SQLModel more like an a real ORM
- Host: GitHub
- URL: https://github.com/iloveitaly/activemodel
- Owner: iloveitaly
- License: mit
- Created: 2024-11-10T04:31:09.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-11-26T23:54:40.000Z (2 months ago)
- Last Synced: 2024-11-27T00:25:45.092Z (2 months ago)
- Topics: activemodel, activerecord, orm, sqlalchemy, sqlmodel
- Language: Python
- Homepage: https://github.com/iloveitaly/activemodel
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActiveModel: ORM Wrapper for SQLModel
No, this isn't *really* [ActiveModel](https://guides.rubyonrails.org/active_model_basics.html). It's just a wrapper around SQLModel that provides a more ActiveRecord-like interface.
SQLModel is *not* an ORM. It's a SQL query builder and a schema definition tool.
This package provides a thin wrapper around SQLModel that provides a more ActiveRecord-like interface with things like:
* Timestamp column mixins
* Lifecycle hooks## Limitations
### Validation
SQLModel does not currently support pydantic validations (when `table=True`). This is very surprising, but is actually the intended functionality:
* https://github.com/fastapi/sqlmodel/discussions/897
* https://github.com/fastapi/sqlmodel/pull/1041
* https://github.com/fastapi/sqlmodel/issues/453
* https://github.com/fastapi/sqlmodel/issues/52#issuecomment-1311987732For validation:
* When consuming API data, use a separate shadow model to validate the data with `table=False` and then inherit from that model in a model with `table=True`.
* When validating ORM data, use SQL Alchemy hooks.## Related Projects
* https://github.com/woofz/sqlmodel-basecrud
## Inspiration
* https://github.com/peterdresslar/fastapi-sqlmodel-alembic-pg
* [Albemic instructions](https://github.com/fastapi/sqlmodel/pull/899/files)
* https://github.com/fastapiutils/fastapi-utils/
* https://github.com/fastapi/full-stack-fastapi-template
* https://github.com/DarylStark/my_data/
* https://github.com/petrgazarov/FastAPI-app/tree/main/fastapi_app