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'}
$
Developing
Install package
- Requirement: Poetry 1.*
$ git clone https://github.com/Happy-Kunal/pydantic2avro
$ cd pydantic2avro/
$ 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.2.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file pydantic2avro-0.1.2.tar.gz
.
File metadata
- Download URL: pydantic2avro-0.1.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c300d1899ae4877261835b424cdc672040093fdf62287ced6dc2c6e93a21fb62 |
|
MD5 | 443482265421546ede047e5abf7acdf9 |
|
BLAKE2b-256 | 51c666189f4ea42632de9f39ebb8d11879bbb3e51e4a6365ae6f7dc14fc7f287 |
Provenance
File details
Details for the file pydantic2avro-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pydantic2avro-0.1.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f6b6b2501801909b530ecf45861193122b2a2cc2812f568ed681463c2e3a86d |
|
MD5 | cb43bf66e98100dc1c5abacab474e0b2 |
|
BLAKE2b-256 | 6c6a4e775a8c9fea2bf7fffdd2a34465c01f9275e1f35f7566459ea6bda02363 |