Skip to main content

Custom types for SQLModel/SQLalchemy

Project description

Sql Types

Custom types for SQLModel/SQLalchemy

Usage

from typing import Sequence
from pydantic import BaseModel
from sqlmodel import Field, SQLModel
from sqltypes import PydanticModel, SpaceDelimitedList

class User(BaseModel):
  name: str
  age: int

class MyDBItem(SQLModel, table=True):
  id: int | None = Field(default=None, primary_key=True)
  tags: Sequence[str] = Field(sa_type=SpaceDelimitedList)
  user: User = Field(sa_type=PydanticModel(User))

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

sqltypes-0.1.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

sqltypes-0.1.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

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