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.0.tar.gz (4.0 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.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_extra-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pydantic_extra-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6ea74f138dcbac4827f0b9ff16fab766081a16f7e4c536c3f6eb3b858e8b2ecc
MD5 51e2522bafa01cbefefa840b9cf5692b
BLAKE2b-256 a479969f8bbb968e25a816a7e484465d70687f59b0a2b579122d9344d5099b49

See more details on using hashes here.

File details

Details for the file pydantic_extra-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_extra-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pydantic_extra-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50d960ed1379ed9af416e8f2e6ce924bf7c66339089c15b033c0c89b68a10b65
MD5 f662b989813c48ff0a4b4aa9659620b2
BLAKE2b-256 2a1eb8688679f70dcc33832f3000dab50fb2cfe879a2222afe1b03193e49a040

See more details on using hashes here.

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