Infrastructure de base de données réutilisable pour les projets Baobab.
Project description
baobab-database
Infrastructure SQLite réutilisable pour les projets Baobab, basée sur SQLAlchemy 2.
Fonctionnalités
- Registre de bases nommées (
DatabaseRegistry,DatabaseSettings) - Factory de moteurs avec cache (
EngineFactory) - Sessions et unité de travail transactionnelle (
SessionFactory,UnitOfWork) - Création de schéma ORM (
SchemaManager,Base) - Utilitaires SQLite : résolution de chemins, URL SQLAlchemy, pragmas WAL
Prérequis
- Python 3.11 ou supérieur
- pip
Installation
python -m venv .venv
# Windows
.\.venv\Scripts\Activate.ps1
# Linux / macOS
source .venv/bin/activate
pip install -e .
# avec outils de développement
pip install -e ".[dev]"
Démarrage rapide
from pathlib import Path
from baobab_database.config.database_registry import DatabaseRegistry
from baobab_database.config.database_settings import DatabaseSettings
from baobab_database.core.engine_factory import EngineFactory
from baobab_database.core.schema_manager import SchemaManager
from baobab_database.core.session_factory import SessionFactory
from baobab_database.core.unit_of_work import UnitOfWork
from baobab_database.sqlite.sqlite_path_resolver import SqlitePathResolver
from baobab_database.sqlite.sqlite_pragma_configurator import SqlitePragmaConfigurator
from baobab_database.sqlite.sqlite_url_factory import SqliteUrlFactory
registry = DatabaseRegistry(
{
"default": DatabaseSettings(
name="default",
database_path=Path("data/default.sqlite"),
)
}
)
engine_factory = EngineFactory(
registry=registry,
path_resolver=SqlitePathResolver(),
url_factory=SqliteUrlFactory(),
pragma_configurator=SqlitePragmaConfigurator(),
)
SchemaManager(engine_factory).create_schema("default")
session_factory = SessionFactory(engine_factory)
unit_of_work = UnitOfWork(session_factory)
with unit_of_work.begin("default") as session:
# utiliser session ici
pass
Structure du package
src/baobab_database/
├── config/ # DatabaseSettings, DatabaseRegistry
├── core/ # Base, EngineFactory, SessionFactory, UnitOfWork, SchemaManager
└── sqlite/ # SqlitePathResolver, SqliteUrlFactory, SqlitePragmaConfigurator
Qualité et tests
pytest
coverage run -m pytest && coverage report
black --check src tests
flake8 src tests
pylint src tests
mypy src tests
python -m bandit -r src/baobab_database
Seuil de couverture minimal du projet : 90 %.
Licence
MIT — voir le fichier de licence du dépôt.
Changelog
Voir CHANGELOG.md.
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 baobab_database-1.0.0.tar.gz.
File metadata
- Download URL: baobab_database-1.0.0.tar.gz
- Upload date:
- Size: 47.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20f40a9aa4ff48b36108bc4348ce27cc62b98c7044b848feb1e60c09c3d62fa2
|
|
| MD5 |
38e7169bb6537e6f44f895d9713bd2a5
|
|
| BLAKE2b-256 |
9457f253f98af1145fa9bed4b088a19a4c4c0f1c1383e9378f696215097efa7d
|
Provenance
The following attestation bundles were made for baobab_database-1.0.0.tar.gz:
Publisher:
release.yml on baobabgit/python-baobab-database
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
baobab_database-1.0.0.tar.gz -
Subject digest:
20f40a9aa4ff48b36108bc4348ce27cc62b98c7044b848feb1e60c09c3d62fa2 - Sigstore transparency entry: 1683377386
- Sigstore integration time:
-
Permalink:
baobabgit/python-baobab-database@e6c9538b159007514856a20328af546e31ba7901 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/baobabgit
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e6c9538b159007514856a20328af546e31ba7901 -
Trigger Event:
push
-
Statement type:
File details
Details for the file baobab_database-1.0.0-py3-none-any.whl.
File metadata
- Download URL: baobab_database-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf881b10b6bad20474ba04c603ecb080054489ddf2d4943ab643c827f01afe2
|
|
| MD5 |
6019656deadac9b398c5255e9e2660db
|
|
| BLAKE2b-256 |
4d7bac765533a6bc06dd2d6de99406964e848954639fb4f7232e377e61a9f688
|
Provenance
The following attestation bundles were made for baobab_database-1.0.0-py3-none-any.whl:
Publisher:
release.yml on baobabgit/python-baobab-database
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
baobab_database-1.0.0-py3-none-any.whl -
Subject digest:
dcf881b10b6bad20474ba04c603ecb080054489ddf2d4943ab643c827f01afe2 - Sigstore transparency entry: 1683377529
- Sigstore integration time:
-
Permalink:
baobabgit/python-baobab-database@e6c9538b159007514856a20328af546e31ba7901 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/baobabgit
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e6c9538b159007514856a20328af546e31ba7901 -
Trigger Event:
push
-
Statement type: