# 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-1311987732
For 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.
<!--
This looks neat
https://github.com/DarylStark/my_data/blob/a17b8b3a8463b9953821b89fee895e272f94d2a4/src/my_model/model.py#L155
schema_extra={
'pattern': r'^[a-z0-9_\-\.]+\@[a-z0-9_\-\.]+\.[a-z\.]+$'
},
extra constraints
https://github.com/DarylStark/my_data/blob/a17b8b3a8463b9953821b89fee895e272f94d2a4/src/my_model/model.py#L424C1-L426C6
-->
## 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
Raw data
{
"_id": null,
"home_page": null,
"name": "activemodel",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "sqlmodel, orm, activerecord, activemodel, sqlalchemy",
"author": null,
"author_email": "Michael Bianco <iloveitaly@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/01/bd/7c397142f95f07df4083947472f9ec704df93df68bf3a978f7263e79b282/activemodel-0.5.0.tar.gz",
"platform": null,
"description": "# ActiveModel: ORM Wrapper for SQLModel\n\nNo, 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.\n\nSQLModel is *not* an ORM. It's a SQL query builder and a schema definition tool.\n\nThis package provides a thin wrapper around SQLModel that provides a more ActiveRecord-like interface with things like:\n\n* Timestamp column mixins\n* Lifecycle hooks\n\n## Limitations\n\n### Validation\n\nSQLModel does not currently support pydantic validations (when `table=True`). This is very surprising, but is actually the intended functionality:\n\n* https://github.com/fastapi/sqlmodel/discussions/897\n* https://github.com/fastapi/sqlmodel/pull/1041\n* https://github.com/fastapi/sqlmodel/issues/453\n* https://github.com/fastapi/sqlmodel/issues/52#issuecomment-1311987732\n\nFor validation:\n\n* 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`.\n* When validating ORM data, use SQL Alchemy hooks.\n\n<!--\n\nThis looks neat\nhttps://github.com/DarylStark/my_data/blob/a17b8b3a8463b9953821b89fee895e272f94d2a4/src/my_model/model.py#L155\n schema_extra={\n 'pattern': r'^[a-z0-9_\\-\\.]+\\@[a-z0-9_\\-\\.]+\\.[a-z\\.]+$'\n },\n\nextra constraints\n\nhttps://github.com/DarylStark/my_data/blob/a17b8b3a8463b9953821b89fee895e272f94d2a4/src/my_model/model.py#L424C1-L426C6\n-->\n## Related Projects\n\n* https://github.com/woofz/sqlmodel-basecrud\n\n## Inspiration\n\n* https://github.com/peterdresslar/fastapi-sqlmodel-alembic-pg\n* [Albemic instructions](https://github.com/fastapi/sqlmodel/pull/899/files)\n* https://github.com/fastapiutils/fastapi-utils/\n* https://github.com/fastapi/full-stack-fastapi-template\n* https://github.com/DarylStark/my_data/\n* https://github.com/petrgazarov/FastAPI-app/tree/main/fastapi_app\n",
"bugtrack_url": null,
"license": null,
"summary": "Make SQLModel more like an a real ORM",
"version": "0.5.0",
"project_urls": {
"Repository": "https://github.com/iloveitaly/activemodel"
},
"split_keywords": [
"sqlmodel",
" orm",
" activerecord",
" activemodel",
" sqlalchemy"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3665d47c99c25e6ab3ece9ca695a7c2e91b32760b303db7c13dbe4768c8fb1c4",
"md5": "b7a9ee0a809c5f07219cdaa6745366a1",
"sha256": "f873f6a2a0a417dcba3fd96e7d68ebbcd1f8c683bb186b81460376f99df1706f"
},
"downloads": -1,
"filename": "activemodel-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b7a9ee0a809c5f07219cdaa6745366a1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 15002,
"upload_time": "2024-11-28T02:32:24",
"upload_time_iso_8601": "2024-11-28T02:32:24.207598Z",
"url": "https://files.pythonhosted.org/packages/36/65/d47c99c25e6ab3ece9ca695a7c2e91b32760b303db7c13dbe4768c8fb1c4/activemodel-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "01bd7c397142f95f07df4083947472f9ec704df93df68bf3a978f7263e79b282",
"md5": "2caaf913f3b0234e218bf4d335ea1282",
"sha256": "904380b1370adc532cc6c4862c50b251ac54a90bcadb4713acde607fe542dd55"
},
"downloads": -1,
"filename": "activemodel-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "2caaf913f3b0234e218bf4d335ea1282",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 12257,
"upload_time": "2024-11-28T02:32:25",
"upload_time_iso_8601": "2024-11-28T02:32:25.123116Z",
"url": "https://files.pythonhosted.org/packages/01/bd/7c397142f95f07df4083947472f9ec704df93df68bf3a978f7263e79b282/activemodel-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-28 02:32:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iloveitaly",
"github_project": "activemodel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "activemodel"
}