Skip to main content

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:

    from sqlapydantic import generate_model
    
    generate_model(models=[MyModel], base_model=CustomBaseModel)
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.

Metadata

Release files for sqlapydantic 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlapydantic 0.0.4
File Size Uploaded
sqlapydantic-0.0.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlapydantic 0.0.4
File Interpreter ABI Platform
sqlapydantic-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / sqlapydantic-0.0.4.tar.gz

Download URL sqlapydantic-0.0.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c6ff737c740c2b10e481890e1ae6891bca1910758d5c646334580584471ac888
BLAKE2b-256 checksum
How to use checksums
7cea46a2040dc4479d7e21ed0fef9d0e084edfffe99ac105f94b783a220e4523
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / sqlapydantic-0.0.4-py3-none-any.whl

Download URL sqlapydantic-0.0.4-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7839ca3c78965ab5fddeccfe3e991c7c3e846d178b9a9490546374bb3ab3b9a0
BLAKE2b-256 checksum
How to use checksums
8dfd71196f5e36f4167de7c424de02b7531e2129b8317491e0ba2f1256b32ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page