Skip to main content

Ginodantic

Project description

Generate pydantic schema from gino models

Python 3.7+
Install: pip install ginodantic

Github: https://github.com/Basalex/ginodantic

Generating custom schemas
  • Meta Class Options
    • as_dataclass: bool -> pydantic dataclass will be used for generated schema

    • as_list_fields: Tuple[str] -> listed fields will be generated as List[type]

    • field_methods: bool -> int and float fields will be generated with postfix __ge, and postfix __le,

    • field_methods_by_name: Dict[str, List[str]] -> use database field names instead of model field names

    • fields: Tuple[str] -> only listed fields will be used for generated schema

    • field_methods: Tuple[str] -> excludes listed fields from generated schema

    • exclude: Tuple[str] -> excludes listed fields from generated schema

    • list_pk: bool -> Foreign key and primary key will be interpreted as list

    • required: Tuple[str] -> only listed fields will be defined as required, can be set as empty tuple

    • use_db_names: bool -> use database field names instead of model field names

Examples of usage:

from ginodantic import BaseModelSchema

class UserSchema(BaseModelSchema):
    class Meta:
        model: User
        required: ()
        exclude: ('email', )
        use_db_names: False
        field_methods_by_name = {'age': ('le', 'ge')}
This would be almost equal to the following schema
class UserSchema(BaseModel):
    id: Optional[int] = None
    username: Optional[str] = None
    age__le: Optional[str] = None
    age__ge: Optional[str] = None

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

ginodantic-0.1.0b2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

ginodantic-0.1.0b2-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

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