All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 32s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 18s
- API-Referenz Seite (/sdk/api-docs) mit ~690 Endpoints, Suche, Filter, Modul-Index - Shared db_utils.py (row_to_dict) + tenant_utils Integration in 6 Route-Dateien - CRUD Factory (crud_factory.py) fuer zukuenftige Module - Version-Route Auto-Registration in versioning_utils.py - 1338 Tests bestanden, -232 Zeilen Duplikat-Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
822 B
Python
26 lines
822 B
Python
"""
|
|
Shared database utility functions for Compliance API routes.
|
|
|
|
Provides common helpers used across multiple route files:
|
|
- row_to_dict: Convert SQLAlchemy Row to JSON-safe dict
|
|
"""
|
|
|
|
from datetime import datetime, date
|
|
from typing import Any, Dict
|
|
|
|
|
|
def row_to_dict(row) -> Dict[str, Any]:
|
|
"""Convert a SQLAlchemy Row/RowMapping to a JSON-serializable dict.
|
|
|
|
Handles datetime serialization and non-standard types.
|
|
"""
|
|
result = dict(row._mapping)
|
|
for key, val in result.items():
|
|
if isinstance(val, datetime):
|
|
result[key] = val.isoformat()
|
|
elif isinstance(val, date):
|
|
result[key] = val.isoformat()
|
|
elif hasattr(val, '__str__') and not isinstance(val, (str, int, float, bool, list, dict, type(None))):
|
|
result[key] = str(val)
|
|
return result
|