Skip to main content

Готовые модели pydantic для частых задач

Project description

pydantic-extra

Данный модуль содержит готовые модели pydantic для частых задач.

установка pip install pydantic-extra

pydantic-extra.smtp

модель MailServer

  • smtp_host - хост
  • smtp_port - порт (по умолчанию: 465)
  • smtp_ssl - использовать ssl (по умолчанию: True)
  • smtp_login/smtp_password - данные для авторизации
  • from_addr - имя отправителя (по умолчанию: smtp_login)

pydantic-extra.db

Требует дополнительные зависимости db (sqlalchemy)
pip install pydantic-extra[db]

модели DB(базовая модель), SQLite, Mysql(в т.ч. для MariaDB), AnyDB

SQLite

  • type - sqlite
  • path - путь до БД

AnyDB

  • type - any
  • str - строка подключения для sqlalchemy

Mysql

  • type - mysql или mariadb
  • host - хост
  • port - порт (по умолчанию: 3306)
  • login/password - данные для авторизации
  • encoding - кодировка (по умолчанию: utf8mb4)
  • database - имя БД

DB

  • connect_str() - возвращает строку подключения для sqlalchemy или sqlalchemy.URL
  • setup() - настраивает sqlalchemy для работы с данным диалектом

использование

from pydantic import BaseModel, Field
from pydantic_extra.db import T_DB


class ExampleConfig(BaseModel):
    db: T_DB = Field(discriminator='type')

С базой данной SQLite по умолчанию

from pathlib import Path

from pydantic import BaseModel, Field
from pydantic_extra.db import T_DB, SQLite


class ExampleConfig(BaseModel):
    db: T_DB = Field(SQLite(type="sqlite", path=Path('example.sqlite')), discriminator='type')

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_extra-1.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

pydantic_extra-1.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_extra-1.0.2.tar.gz.

File metadata

  • Download URL: pydantic_extra-1.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydantic_extra-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1a79afa8ed84f5ef751e5f9b578ce6e66cbd1cc7df2bc8b53c7b4fdb80b3377a
MD5 5883727d07108f1564c91c1f24cb74c2
BLAKE2b-256 6c6f56475dfc86cfd0be746f5fc27e08059c207564174e8a1eee18b1bb610d30

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_extra-1.0.2.tar.gz:

Publisher: release.yml on zedzhen/pydantic-extra

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_extra-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pydantic_extra-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydantic_extra-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b46d2815c1bee90cc1b8fbf9fba9a290e9cfad25b68bf13607f1eb8217edd4d
MD5 0900dcb1c0081984597241d70c24e373
BLAKE2b-256 aceeb0f21610be6c27c8fb7c1dd83757e7c1faf6baa7e6bc601a19d4d00aba7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_extra-1.0.2-py3-none-any.whl:

Publisher: release.yml on zedzhen/pydantic-extra

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