Skip to main content

Generate Apache Avro schemas for Pydantic data models.

Project description

pydantic2avro

Generate Apache Avro schemas for Pydantic data models.

Install

pip install pydantic2avro

Example

  • Create a file main.py with:
from pprint import pprint
from uuid import UUID

from pydantic import BaseModel
from pydantic2avro import PydanticToAvroSchemaMaker


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

schema = PydanticToAvroSchemaMaker(User).get_schema()
pprint(schema)
  • Run it
$ python main.py 
{'fields': [{'name': 'id', 'type': {'logicalType': 'uuid', 'type': 'string'}},
            {'name': 'name', 'type': 'string'},
            {'name': 'age', 'type': 'long'}],
 'name': 'User',
 'type': 'record'}
$

DevelopingInstall for developers

Install package
  • Requirement: Poetry 1.*
poetry install
Run unit tests
pytest
coverage run -m pytest  # with coverage
# or (depends on your local env) 
poetry run pytest
poetry run coverage run -m pytest  # with coverage

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

pydantic2avro-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

pydantic2avro-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantic2avro-0.1.1.tar.gz.

File metadata

  • Download URL: pydantic2avro-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.1 CPython/3.12.2 Linux/6.7.5-200.fc39.x86_64

File hashes

Hashes for pydantic2avro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 942bf8d737d918541765486ab0351279d3f74318f2848113be961d0a9ad88ee4
MD5 acfd7257b37d0a305edafadff4384eec
BLAKE2b-256 41ea9681d9c5efe9a448766014250164b61cb44f9648d05874f538f6866a49e9

See more details on using hashes here.

Provenance

File details

Details for the file pydantic2avro-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pydantic2avro-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.1 CPython/3.12.2 Linux/6.7.5-200.fc39.x86_64

File hashes

Hashes for pydantic2avro-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2510c4e52edb9dc9254d961c5910a68d250919df866cef4ef4db26f0a1310325
MD5 0c2a5682e60d3579ccef7adf78b177d2
BLAKE2b-256 5c33885ab20ec9e65a987ff54da02d2c3f2d185494e4a11489fb4e6e1b873a87

See more details on using hashes here.

Provenance

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