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.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for protobuf_pydantic_gen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f38d7c8f22e6ae5dfc2787d7b3b85699a88bc3cd4942b71fdaeca3eff7e593cd
MD5 b06487209c8c3b424261a3b1adc22eaf
BLAKE2b-256 e39dc8c8be8e1ae362d6ead5a26fa783c4db922894d6120d3a419a26e1ad0283

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for protobuf_pydantic_gen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35b3330ee6b2caee5bd5c3b476fa2def6a08b1a1a19803372ca267f890752986
MD5 b262ab7f4a78383dcabb26fa91650bb4
BLAKE2b-256 d324352575fdfed2d14ddbaaedb359873a080de03d6c0cf310c2af8bc3d3090b

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