Metadata-Version: 2.1
Name: sqlapydantic
Version: 0.0.4
Summary: Generate pydantic models from SQLAlchemy models
Home-page: https://github.com/maacck/sqlapydantic
Keywords: pydantic,sqlalchemy
Author: maacck
Author-email: c.mai@madainchina.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: SQLAlchemy (>=2.0.13,<3.0.0)
Requires-Dist: pydantic (>=2.0.2,<3.0.0)
Project-URL: BUG TRACKER, https://github.com/maacck/sqlapydantic/issues
Project-URL: Repository, https://github.com/maacck/sqlapydantic
Description-Content-Type: text/markdown

# 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.

