Skip to main content

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_protobuffrom_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protobuf_pydantic_gen-0.1.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

protobuf_pydantic_gen-0.1.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

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

Hashes for protobuf_pydantic_gen-0.1.3.tar.gz
Algorithm Hash digest
SHA256 474c1091faed25c5d4f9d20c74196994d2bf3a2b568b5e1731bffa69bd74fb0e
MD5 b219b3d8f7f77a91258122cdb66559ec
BLAKE2b-256 31759df7c9d76d37de7eabf05f6e46d34a9fc5341134e1045846a93d8f318fee

See more details on using hashes here.

File details

Details for the file protobuf_pydantic_gen-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for protobuf_pydantic_gen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a78c53c326d438b66a66d8d7f22e31d069ce67798d63b0776bee0a05c2050b8f
MD5 98681afcad0b3eaf3891f9afb949291f
BLAKE2b-256 1211140c05ce950bc6e1ca4a6b4060c6dbc88e81022b8c0a502b71d0c9f1fea6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page