Skip to main content

Python Relations Package

简体中文

GitHub License GitHub Downloads (all assets, all releases)

A flexible, type-safe relationship management system for Python models built on top of Pydantic [source|PyPI]. Provides ORM-style relationships with caching support and strict type checking through Pydantic's validation system.

Features

  • Built on Pydantic for robust data validation and serialization
  • Type-safe relationship declarations with full type hints support
  • Configurable caching with TTL support
  • Support for common relationship types (BelongsTo, HasOne, HasMany)
  • Flexible query and loading interfaces
  • Automatic relationship validation
  • Forward reference support for circular dependencies

Requirements

  • Python >= 3.8
  • pydantic >= 2.0

Development Requirements

  • pytest >= 7.0 (for testing)
  • coverage >= 7.0 (for test coverage)

Quick Start

from typing import ClassVar
from pydantic import BaseModel
from relations import RelationManagementMixin, HasMany, BelongsTo

class Department(RelationManagementMixin, BaseModel):
    id: int
    name: str
    employees: ClassVar[HasMany["Employee"]] = HasMany(
        foreign_key="department_id",
        inverse_of="department"
    )

class Employee(RelationManagementMixin, BaseModel):
    id: int
    name: str
    department_id: int
    department: ClassVar[BelongsTo["Department"]] = BelongsTo(
        foreign_key="department_id",
        inverse_of="employees"
    )

Documentation

Detailed documentation is available in the following sections:

License

MIT License

Metadata

Release files for python-relations 0.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-relations 0.1.0.post1
File Size Uploaded
python_relations-0.1.0.post1.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-relations 0.1.0.post1
File Interpreter ABI Platform
python_relations-0.1.0.post1-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / python_relations-0.1.0.post1.tar.gz

Download URL python_relations-0.1.0.post1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7bc1c880d459f1c3591bd7e069697d7b297c6e4faf30403fd0070048cf300bbb
BLAKE2b-256 checksum
How to use checksums
fb6b4c00c00627d08e5a70dd199ba817bf88cd9f2206282c4c4e20395384506a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / python_relations-0.1.0.post1-py3-none-any.whl

Download URL python_relations-0.1.0.post1-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6aee741378e6dc0a4dfa15e32e3b1a0e48ed0e895dec76fafc7444bbb35d125e
BLAKE2b-256 checksum
How to use checksums
f872e310f1bb9dc2bac59fd2f983ac117776e433668cd608ad6c5f001998a0e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.0.post1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page