Generate Avro Schemas from a Python class
Project description
Dataclasses Avro Schema Generator
Generate Avro Schemas from a Python class
Requirements:
python 3.7+
Installation
pip install dataclasses-avroschema
Doocumentaion
https://marcosschroh.github.io/dataclasses-avroschema/
Usage:
from dataclasses_avroschema.schema_generator import SchemaGenerator
class User:
"An User"
name: str
age: int
pets: typing.List[str]
accounts: typing.Dict[str, int]
favorite_colors: typing.Tuple[str] = ("BLUE", "YELLOW", "GREEN")
country: str = "Argentina"
address: str = None
SchemaGenerator(User).avro_schema()
'{
"type": "record",
"name": "User",
"doc": "An User",
"fields": [
{"name": "name", "type": "string"},
{"name": "age", "type": "int"},
{"name": "pets", "type": "array", "items": "string"},
{"name": "accounts", "type": "map", "values": "int"},
{"name": "favorite_colors", "type": "enum", "symbols": ["BLUE", "YELLOW", "GREEN"]},
{"name": "country", "type": ["string", "null"], "default": "Argentina"},
{"name": "address", "type": ["null", "string"], "default": "null"}
]
}'
Features:
- Primitive types: int, long, float, boolean, string and null support
- Complex types: enum, array, map, unions and records support
- Logical Types: date, time, datetime, uuid support
- Schema relations (oneToOne, oneToMany)
- Recursive Schemas
- Generate Avro Schemas from
faust.Record
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
Close
Hashes for dataclasses-avroschema-0.7.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eff64107ff01ba570a526c386060f2268b129ab17687826b0cb3773449278c5c |
|
MD5 | 9225297cc573d221685d8a77dfecf565 |
|
BLAKE2b-256 | 76dbd61ec42e13fe7ba73ce5c63a5e9ab7cc82a54dc1f3000cf021e01b434deb |