Skip to main content

voltwire-db-types-json

Custom SQLAlchemy column types for PostgreSQL JSONB columns, backed by Pydantic models. Handles serialisation, deserialisation, and validation transparently — your columns read and write Pydantic model instances directly.

Installation

pip install voltwire-db-types-json
# or with Poetry:
poetry add voltwire-db-types-json

Types

JSONBList[T] — JSONB array as a list of Pydantic models

Returns an empty list when the column value is NULL.

from pydantic import BaseModel
from sqlalchemy.orm import mapped_column, Mapped
from voltwire.db.types.json import JSONBList

class Tag(BaseModel):
    name: str
    colour: str

class Article(Base):
    __tablename__ = "articles"
    tags: Mapped[list[Tag]] = mapped_column(JSONBList(Tag), default=list)

JSONBObject[T] — JSONB object as a single Pydantic model

Returns None when the column value is NULL or validation fails (logs an error, does not raise).

from voltwire.db.types.json import JSONBObject

class Address(BaseModel):
    street: str
    city: str

class User(Base):
    __tablename__ = "users"
    address: Mapped[Address | None] = mapped_column(JSONBObject(Address), nullable=True)

Logging

Validation errors in JSONBObject are logged to the voltwire.db.types.json.types logger namespace and return None rather than raising — this prevents a single bad row from crashing the application.

import logging
logging.getLogger("voltwire.db.types.json").setLevel(logging.DEBUG)

Download files

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

Source Distribution

voltwire_db_types_json-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

voltwire_db_types_json-0.0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: voltwire_db_types_json-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for voltwire_db_types_json-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fd453f61226b28f66a85f224f10e54b6af5a84bf184928c6c7a23a3146f1c782
MD5 2da892eecda8972894a2a05b9ad18d80
BLAKE2b-256 3bce030718708c335c1074cc90109cdea98b874dac8f0a71dbde1dc3f1f389f2

See more details on using hashes here.

File details

Details for the file voltwire_db_types_json-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: voltwire_db_types_json-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for voltwire_db_types_json-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03c5dc097deefeb804d308abb5575f346b9fe5ba5d833519d8b89122f77386a4
MD5 91e4d92f97408a31796b7d236a638278
BLAKE2b-256 f3db432c1df22ccd8706e63db66812c0cb5583da3c1569a75711151127299891

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 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