A Python library for managing model relationships
Project description
Python Relations Package
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_relations-0.1.0.post1.tar.gz.
File metadata
- Download URL: python_relations-0.1.0.post1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bc1c880d459f1c3591bd7e069697d7b297c6e4faf30403fd0070048cf300bbb
|
|
| MD5 |
a3904d869a7c539295918bfd18daee89
|
|
| BLAKE2b-256 |
fb6b4c00c00627d08e5a70dd199ba817bf88cd9f2206282c4c4e20395384506a
|
File details
Details for the file python_relations-0.1.0.post1-py3-none-any.whl.
File metadata
- Download URL: python_relations-0.1.0.post1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aee741378e6dc0a4dfa15e32e3b1a0e48ed0e895dec76fafc7444bbb35d125e
|
|
| MD5 |
d5457d188aeddd55229cac554f8b8732
|
|
| BLAKE2b-256 |
f872e310f1bb9dc2bac59fd2f983ac117776e433668cd608ad6c5f001998a0e8
|