Skip to main content

Seamlessly use Pydantic 2 models in a Postgres SQLAlchemy model

Project description

pydantic-sqlalchemy-type-decorator

Seamlessly use Pydantic 2 models in a Postgres SQLAlchemy model

Installation

The package is available on pypi.

You can install this package using pip:

pip install pydantic_sqlalchemy_deco

Usage

Given some Pydantic model called MyCustomModel, you can specify your columns like:

from pydantic_sqlalchemy_deco.decorator import PydanticJSON

...

class MyTable(Base):

    response: Mapped[MyCustomModel] = mapped_column(PydanticJSON(MyCustomModel))

BaseModel changes

If your BaseModel has custom serializers, you can specify this using the T parameter:

    response: Mapped[MyCustomModel] = mapped_column(PydanticJSON[CoolerBaseModel](MyCustomModel))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_sqlalchemy_deco-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_sqlalchemy_deco-0.0.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_sqlalchemy_deco-0.0.3.tar.gz.

File metadata

  • Download URL: pydantic_sqlalchemy_deco-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pydantic_sqlalchemy_deco-0.0.3.tar.gz
Algorithm Hash digest
SHA256 508952aa4eb626cfc70bed3e24948d2066865fb3fe1d4af23ec2f368ff67c016
MD5 43f4f80b67df73b2e80ba6adc28c1a11
BLAKE2b-256 d8564b7f6fef8df3fb93dbe7b718e18b52e7a2ac034230482c807ed3048620a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sqlalchemy_deco-0.0.3.tar.gz:

Publisher: python-publish.yml on kevinhikaruevans/pydantic-sqlalchemy-type-decorator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_sqlalchemy_deco-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_sqlalchemy_deco-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 41d851939465bc899ff26d4ca7440ecb47660ea93687b6d6d2f403b2d1df3575
MD5 61d6ddf0b27a0f5c3ddd02a690ffd4ed
BLAKE2b-256 169a41c39f3dab3fcace6522d808cead5f7f727d472895351c3d7bf5c7a1f718

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sqlalchemy_deco-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on kevinhikaruevans/pydantic-sqlalchemy-type-decorator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page