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.2.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.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_sqlalchemy_deco-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 39afb27d395eba40bdb0a43007ceada4085fd704e99f289475196470c0990063
MD5 4b4db6cc3de0eb96224353f6b89c0ef4
BLAKE2b-256 1b414ac0e2ce9340a6c2981fc3ae460c9b4c5a9e339deecd7f4bc702d236f2f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sqlalchemy_deco-0.0.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_sqlalchemy_deco-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d281c0f2848d5c18bfda9fb71df25110246de06c4c8f440dd5533e5716ceaeb8
MD5 7798ffe1e8e0771260fb9059c539f5a1
BLAKE2b-256 e0dba5b539fd35caf5a8bc261ea1d60a2ee08b056aad61f2300bc9db9ce7d4e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sqlalchemy_deco-0.0.2-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