A tool for converting between Pydantic models and Protobuf messages, specifically enabling the generation of Pydantic BaseModel classes from .proto files.
Project description
protobuf-pydantic-gen
pydantic model 和 protobuf message 互相转换工具,实现.proto
文件生成pydantic BaseModel
类。
特性
-
支持protobuf基本类型转换为python基本类型
-
支持protobuf描述语言转换为pydantic
BaseModel
类 -
支持protobuf描述语言转换为
sqlmodel
ORM模型 -
为
BaseModel
类实现to_protobuf
和from_protobuf
方法,实现pydantic model 和 protobuf message 互相转换 -
为protobuf 描述文件提供
pydantic BaseModel
字段的参数选项
安装
pip install protobuf-pydantic-gen
使用
python3 -m grpc_tools.protoc --proto_path=./protos -I=./protos -I=./ --python_out=./pb --pyi_out=./pb --grpc_python_out=./pb --pydantic_out=./models "./protos/example.proto"
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
Built Distribution
File details
Details for the file protobuf_pydantic_gen-0.1.2.tar.gz
.
File metadata
- Download URL: protobuf_pydantic_gen-0.1.2.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f38d7c8f22e6ae5dfc2787d7b3b85699a88bc3cd4942b71fdaeca3eff7e593cd |
|
MD5 | b06487209c8c3b424261a3b1adc22eaf |
|
BLAKE2b-256 | e39dc8c8be8e1ae362d6ead5a26fa783c4db922894d6120d3a419a26e1ad0283 |
File details
Details for the file protobuf_pydantic_gen-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: protobuf_pydantic_gen-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35b3330ee6b2caee5bd5c3b476fa2def6a08b1a1a19803372ca267f890752986 |
|
MD5 | b262ab7f4a78383dcabb26fa91650bb4 |
|
BLAKE2b-256 | d324352575fdfed2d14ddbaaedb359873a080de03d6c0cf310c2af8bc3d3090b |