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:
- int, long, float, boolean, string and null support
- enum, array, map and records support
- Schema relations (oneToOne, oneToMany)
- Recursive Schemas
- Support for Avro Logical Types
- Custom Exceptions?
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.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f0132b4860d98c938e09db5df1de22cb521b9697ce9485af6e1d6521c4be7e7 |
|
MD5 | c3d0afb7c01daa5bc01d61481cf240b6 |
|
BLAKE2b-256 | c2529c9baa5771f8a23d02d980806ca1603dbdf10169417b69fbaa8716b36fdd |