Framework-agnostic validation engine for Data Quality Language (DQL)
Project description
dql-core
Framework-agnostic validation engine for Data Quality Language (DQL).
Documentation | PyPI | GitHub
dql-core provides the abstract validation, cleaner, and executor framework that can be implemented for any Python framework (Django, Flask, FastAPI, SQLAlchemy, Pandas, etc.). It handles the business logic of DQL validation without being tied to any specific data access layer.
Installation
pip install dql-core
Quick Start
Creating a Custom Executor
from dql_core import ValidationExecutor
from dql_parser import parse_dql
class MyExecutor(ValidationExecutor):
"""Custom executor for your framework."""
def get_records(self, model_name: str):
# Return records from your data source
return my_database.query(model_name).all()
def filter_records(self, records, condition):
# Apply filtering logic
return [r for r in records if self.evaluate_condition(r, condition)]
def count_records(self, records):
return len(list(records))
def get_field_value(self, record, field_name: str):
# Get field value from your record type
return getattr(record, field_name)
# Parse DQL and execute validation
dql_text = """
from Customer
expect column("email") to_not_be_null
expect column("age") to_be_between(18, 100)
"""
ast = parse_dql(dql_text)
executor = MyExecutor()
result = executor.execute(ast)
print(f"Validation passed: {result.overall_passed}")
print(f"Expectations: {result.total_expectations}")
print(f"Failed: {result.failed_expectations}")
Features
Abstract Validation Framework
- 6 Built-in Validators:
to_be_null,to_not_be_null,to_match_pattern,to_be_between,to_be_in,to_be_unique - Custom Validators: Extend
Validatorbase class - Validator Registry: Register validators for operators
- Framework-Agnostic: Works with any data source (Django ORM, SQLAlchemy, Pandas, raw dicts)
Abstract Executor
- Template Method Pattern: Implement 4 abstract methods, get full validation logic
- Multi-Model Support: Validate multiple models in one DQL file
- Rich Results: Detailed validation results with failure info
- Severity Levels: Support for critical, warning, info
Cleaner Framework
- Transaction Safety: Built-in transaction management template
- Registry Pattern: Register cleaners by name
- Decorator Support:
@register_cleanerfor easy registration - Error Handling: Automatic rollback on failure
External API Adapters
- Adapter Pattern: Create adapters for external APIs
- Rate Limiting: Built-in rate limiter
- Retry Logic: Exponential backoff retry utilities
- Factory Pattern: APIAdapterFactory for creating adapters
Built-in Validators
to_be_null / to_not_be_null
expect column("optional_field") to_be_null
expect column("required_field") to_not_be_null
to_match_pattern
expect column("email") to_match_pattern("^[\\w\\.-]+@[\\w\\.-]+\\.\\w+$")
expect column("phone") to_match_pattern("^\\d{3}-\\d{3}-\\d{4}$")
to_be_between
expect column("age") to_be_between(18, 120)
expect column("price") to_be_between(0.0, 9999.99)
to_be_in
expect column("status") to_be_in("active", "inactive", "pending")
expect column("category") to_be_in("A", "B", "C")
to_be_unique
expect column("email") to_be_unique
expect column("username") to_be_unique
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black dql_core tests
License
MIT License - see LICENSE file for details.
Documentation
Full documentation: https://yourusername.github.io/dql-core/
- Concepts - Core architecture
- Validator Guide - Create custom validators
- Cleaner Guide - Write cleaner functions
- Executor Guide - Implement framework executors
- API Reference - Complete API
Related Packages
- dql-parser - Pure Python DQL parser (docs)
- django-dqm - Django integration (docs)
Package Selection
Not sure which package to use? See the Package Selection Guide
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 dql_core-0.1.0.tar.gz.
File metadata
- Download URL: dql_core-0.1.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7952482e7d2c6347d30dd7b718a73d3ab6c6e5d732aa11af142f13a1c954ff4c
|
|
| MD5 |
42849b3017f02de407ef46b245c5e13e
|
|
| BLAKE2b-256 |
8bbbe01e99de5aa6c5fb1488832600e6d065df8a27dee3aaf826d987a392a16a
|
File details
Details for the file dql_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dql_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
601f767624c5512f04f54b810a72b73f5036e8a2768407fcc588738ab1818a7d
|
|
| MD5 |
f2e718346fbe16f40fcaad9f6f10c1a2
|
|
| BLAKE2b-256 |
1758eb4f42d3ec47e3a73e9b83af8fb689d5a171ae5540f234914a0095e0d82e
|