Converting pydantic classes to avro schemas
Project description
pydantic-avro
This library can convert a pydantic class to a avro schema or generate python code from a avro schema.
Install
pip install pydantic-avro
Pydantic class to avro schema
import json
from typing import Optional
from pydantic_avro.base import AvroBase
class TestModel(AvroBase):
key1: str
key2: int
key2: Optional[str]
schema_dict: dict = TestModel.avro_schema()
print(json.dumps(schema_dict))
Avro schema to pydantic
#!/usr/bin/env bash
# Print to stdout
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc
# Save it to a file
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc --output /path/to/output.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydantic-avro-0.0.3.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_avro-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f49d162433d8e45066aaeeac3d946103450c95b862ccdf323d551476add3b6a |
|
MD5 | 51da688ef9a618fc551681c8cb34a35e |
|
BLAKE2b-256 | caa2dcf6f253cde59557b1e4b6ee7b82cf18210bd6f04c74424db1fcead1111e |