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

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.1.tar.gz (4.5 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.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_sqlalchemy_deco-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 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.1.tar.gz
Algorithm Hash digest
SHA256 8a3f06229ce7be4fb870b75b9b495915b8d468c1a2e62f976705bfcba49e76a7
MD5 f9aa66670ef10355478173ce935e73e8
BLAKE2b-256 6412c477c42a5de0efa4d1801103538828d126609a4d99c02545e989b4eccc67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pydantic_sqlalchemy_deco-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e00012c6672bab65542d15774a8e408999d9f4c5bc078ff596e75f442a96825d
MD5 b0f43076d56d206aaebf974e6e24ddd1
BLAKE2b-256 813c98f95d24adacbace03c41902e3c9d456bad2e2a6ef54d2c4c88e89d65252

See more details on using hashes here.

Provenance

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