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.3.tar.gz
.
File metadata
- Download URL: protobuf_pydantic_gen-0.1.3.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 | 474c1091faed25c5d4f9d20c74196994d2bf3a2b568b5e1731bffa69bd74fb0e |
|
MD5 | b219b3d8f7f77a91258122cdb66559ec |
|
BLAKE2b-256 | 31759df7c9d76d37de7eabf05f6e46d34a9fc5341134e1045846a93d8f318fee |
File details
Details for the file protobuf_pydantic_gen-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: protobuf_pydantic_gen-0.1.3-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 | a78c53c326d438b66a66d8d7f22e31d069ce67798d63b0776bee0a05c2050b8f |
|
MD5 | 98681afcad0b3eaf3891f9afb949291f |
|
BLAKE2b-256 | 1211140c05ce950bc6e1ca4a6b4060c6dbc88e81022b8c0a502b71d0c9f1fea6 |