Skip to content

Commit 0da4561

Browse files
committed
Add Python implementation of DataJam library
Implement complete Python port of .NET DataJam with: - Core abstractions mirroring .NET interfaces (IDataContext, IRepository, IUnitOfWork, etc.) - SQLAlchemy-based implementation with async support - Oracle-specific utilities for case sensitivity and sequences - Comprehensive build automation using Nox (equivalent to NUKE) - Modern Python tooling (ruff, black, mypy, pytest) with proper type hints - Project structure following Python packaging standards - Test framework foundation with TestContainers support The implementation maintains the same architectural patterns as the .NET version while being properly adapted for Python idioms and async/await patterns.
1 parent 9a5351e commit 0da4561

18 files changed

Lines changed: 1416 additions & 1 deletion

.gitignore

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,74 @@ FodyWeavers.xsd
402402
*.bak
403403

404404
# Nuke's temp directory
405-
.nuke/temp/
405+
.nuke/temp/
406+
407+
# Python
408+
__pycache__/
409+
*.py[cod]
410+
*$py.class
411+
*.so
412+
.Python
413+
build/
414+
develop-eggs/
415+
dist/
416+
downloads/
417+
eggs/
418+
.eggs/
419+
lib/
420+
lib64/
421+
parts/
422+
sdist/
423+
var/
424+
wheels/
425+
share/python-wheels/
426+
*.egg-info/
427+
.installed.cfg
428+
*.egg
429+
MANIFEST
430+
431+
# PyInstaller
432+
*.manifest
433+
*.spec
434+
435+
# Unit test / coverage reports
436+
htmlcov/
437+
.tox/
438+
.nox/
439+
.coverage
440+
.coverage.*
441+
.cache
442+
nosetests.xml
443+
coverage.xml
444+
*.cover
445+
*.py,cover
446+
.hypothesis/
447+
.pytest_cache/
448+
cover/
449+
450+
# Virtual environments
451+
.env
452+
.venv
453+
env/
454+
venv/
455+
ENV/
456+
env.bak/
457+
venv.bak/
458+
459+
# mypy
460+
.mypy_cache/
461+
.dmypy.json
462+
dmypy.json
463+
464+
# Pyre type checker
465+
.pyre/
466+
467+
# pytype static type analyzer
468+
.pytype/
469+
470+
# Python artifacts in root
471+
python/artifacts/
472+
python/.nox/
473+
python/htmlcov/
474+
python/.coverage
475+
python/.pytest_cache/

python/.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
11+
- repo: https://github.com/psf/black
12+
rev: 23.9.1
13+
hooks:
14+
- id: black
15+
language_version: python3
16+
17+
- repo: https://github.com/pycqa/isort
18+
rev: 5.12.0
19+
hooks:
20+
- id: isort
21+
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.1.3
24+
hooks:
25+
- id: ruff
26+
args: [--fix, --exit-non-zero-on-fix]
27+
28+
- repo: https://github.com/pre-commit/mirrors-mypy
29+
rev: v1.5.1
30+
hooks:
31+
- id: mypy
32+
additional_dependencies: [types-all]
33+
args: [--strict, --ignore-missing-imports]

python/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# DataJam Python
2+
3+
DataJam provides abstraction patterns for data access across different ORM technologies in Python. This is a Python port of the .NET DataJam library, following domain-driven design principles with clear separation of concerns.
4+
5+
## Features
6+
7+
- **Domain-Driven Architecture**: Organize data access around domains that encapsulate related entities and configuration
8+
- **Multi-ORM Support**: Currently supports SQLAlchemy with extensible architecture for other ORMs
9+
- **Command/Query Pattern**: Separate command objects for operations that don't return values
10+
- **Repository Pattern**: Abstract data access through repository interfaces
11+
- **Unit of Work Pattern**: Manage transaction boundaries and change tracking
12+
- **Oracle Support**: First-class support for Oracle databases with proper case sensitivity handling
13+
14+
## Quick Start
15+
16+
```python
17+
from datajam import IRepository, IDataContext
18+
from datajam_sqlalchemy import DataContext, Domain
19+
20+
# Define your domain
21+
class MyDomain(Domain):
22+
def configure_mappings(self, metadata):
23+
# Configure your entity mappings
24+
pass
25+
26+
# Use the repository
27+
domain = MyDomain(connection_string="your_connection_string")
28+
with DataContext(domain) as context:
29+
repository = context.repository
30+
31+
# Execute commands and queries
32+
result = repository.find(MyQuery())
33+
```
34+
35+
## Installation
36+
37+
```bash
38+
# Basic installation
39+
pip install datajam
40+
41+
# With SQLAlchemy support
42+
pip install datajam[sqlalchemy]
43+
44+
# For development
45+
pip install datajam[dev]
46+
```
47+
48+
## Development
49+
50+
This project uses Nox for build automation (equivalent to NUKE in .NET):
51+
52+
```bash
53+
# Setup development environment
54+
nox -s dev-setup
55+
56+
# Run tests
57+
nox -s test
58+
59+
# Run integration tests (requires Docker)
60+
nox -s test-integration
61+
62+
# Run linting
63+
nox -s lint
64+
65+
# Format code
66+
nox -s format
67+
68+
# Full build pipeline
69+
nox -s datajam
70+
```
71+
72+
## Architecture
73+
74+
The library follows the same architectural patterns as the .NET DataJam:
75+
76+
- **Core abstractions** (`datajam` package): Interfaces and base classes
77+
- **SQLAlchemy implementation** (`datajam_sqlalchemy` package): SQLAlchemy-specific implementations
78+
- **Testing utilities** (`datajam_testing` package): Test helpers and patterns
79+
80+
## Testing
81+
82+
Integration tests use TestContainers for database provisioning, ensuring tests run against real database instances:
83+
84+
```bash
85+
# Run all tests
86+
nox -s test-all
87+
88+
# Run only Oracle integration tests
89+
nox -s test-integration -- tests/integration/oracle/
90+
```
91+
92+
## License
93+
94+
MIT License - see LICENSE file for details.

0 commit comments

Comments
 (0)