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
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)
| File | Size | Uploaded | |
|---|---|---|---|
| python_relations-0.1.0.post1.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|