# sqlapydantic
Generate Pydantic Model from SQLAlchemy Model
This package is helpful while building web apps with FastAPI and SQLAlchemy. It generates Pydantic Model from SQLAlchemy Model.
Installation
============
To install,
pip install sqlapydantic
Quickstart
==========
You may use `generate_models` function directly to generate Pydantic Model from SQLAlchemy Model. It takes `Generator`'s init arguments and init a Generator class.
Examples:
```python
from sqlapydantic import generate_model
generate_model(models=[MyModel], base_model=CustomBaseModel)
```
```python
from sqlapydantic import Generator
generator = Generator(base_model=CustomBaseModel)
generator.generate_from_module(models=my_models_module, output_path="schemas.py")
```
Generator Class takes following init arguments
- `split_models`: Whether to split models into Base, Create, Update and Read models. Default is `Fakse`.
- `base_model`: Base model to inherit from. Default is `BaseModel` from `pydantic`.
- `restrict_fields`: Which takes a `set` of fields to restrict. Default is `None`. This is useful when you want to restrict some fields to be readonly such as id, created_at, updated_at.
- `indentation`: Indentation to use in generated code.
## RoadMap
- Strict typing, such as using `conint` for limiting `Integer` size and `constr` for `String` length.
- Probably, generate relationships as well.
Raw data
{
"_id": null,
"home_page": "https://github.com/maacck/sqlapydantic",
"name": "sqlapydantic",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "pydantic,sqlalchemy",
"author": "maacck",
"author_email": "c.mai@madainchina.com",
"download_url": "https://files.pythonhosted.org/packages/7c/ea/46a2040dc4479d7e21ed0fef9d0e084edfffe99ac105f94b783a220e4523/sqlapydantic-0.0.4.tar.gz",
"platform": null,
"description": "# sqlapydantic\n\nGenerate Pydantic Model from SQLAlchemy Model\n\nThis package is helpful while building web apps with FastAPI and SQLAlchemy. It generates Pydantic Model from SQLAlchemy Model.\n\n\nInstallation\n============\n\nTo install,\n\n pip install sqlapydantic\n\n\nQuickstart\n==========\n\nYou may use `generate_models` function directly to generate Pydantic Model from SQLAlchemy Model. It takes `Generator`'s init arguments and init a Generator class. \n\nExamples:\n\n```python\n from sqlapydantic import generate_model\n \n generate_model(models=[MyModel], base_model=CustomBaseModel)\n\n```\n\n```python\nfrom sqlapydantic import Generator\n\ngenerator = Generator(base_model=CustomBaseModel)\ngenerator.generate_from_module(models=my_models_module, output_path=\"schemas.py\")\n```\n\n\nGenerator Class takes following init arguments\n- `split_models`: Whether to split models into Base, Create, Update and Read models. Default is `Fakse`.\n- `base_model`: Base model to inherit from. Default is `BaseModel` from `pydantic`.\n- `restrict_fields`: Which takes a `set` of fields to restrict. Default is `None`. This is useful when you want to restrict some fields to be readonly such as id, created_at, updated_at.\n- `indentation`: Indentation to use in generated code.\n\n\n## RoadMap\n- Strict typing, such as using `conint` for limiting `Integer` size and `constr` for `String` length.\n- Probably, generate relationships as well.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Generate pydantic models from SQLAlchemy models",
"version": "0.0.4",
"project_urls": {
"BUG TRACKER": "https://github.com/maacck/sqlapydantic/issues",
"Homepage": "https://github.com/maacck/sqlapydantic",
"Repository": "https://github.com/maacck/sqlapydantic"
},
"split_keywords": [
"pydantic",
"sqlalchemy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8dfd71196f5e36f4167de7c424de02b7531e2129b8317491e0ba2f1256b32ef1",
"md5": "1b99136c9deb9c9953bf4bdbfcd4c7b4",
"sha256": "7839ca3c78965ab5fddeccfe3e991c7c3e846d178b9a9490546374bb3ab3b9a0"
},
"downloads": -1,
"filename": "sqlapydantic-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b99136c9deb9c9953bf4bdbfcd4c7b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 7487,
"upload_time": "2023-08-10T15:44:17",
"upload_time_iso_8601": "2023-08-10T15:44:17.409875Z",
"url": "https://files.pythonhosted.org/packages/8d/fd/71196f5e36f4167de7c424de02b7531e2129b8317491e0ba2f1256b32ef1/sqlapydantic-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7cea46a2040dc4479d7e21ed0fef9d0e084edfffe99ac105f94b783a220e4523",
"md5": "af7ee52f35141cff12c81f0d2a578a80",
"sha256": "c6ff737c740c2b10e481890e1ae6891bca1910758d5c646334580584471ac888"
},
"downloads": -1,
"filename": "sqlapydantic-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "af7ee52f35141cff12c81f0d2a578a80",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 5509,
"upload_time": "2023-08-10T15:44:19",
"upload_time_iso_8601": "2023-08-10T15:44:19.134849Z",
"url": "https://files.pythonhosted.org/packages/7c/ea/46a2040dc4479d7e21ed0fef9d0e084edfffe99ac105f94b783a220e4523/sqlapydantic-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-10 15:44:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maacck",
"github_project": "sqlapydantic",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "sqlapydantic"
}