pgsqlasync2fast-fastapi 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {pgsqlasync2fast_fastapi-0.3.0/src/pgsqlasync2fast_fastapi.egg-info → pgsqlasync2fast_fastapi-0.3.1}/PKG-INFO +3 -1
  2. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/README.md +2 -0
  3. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/pyproject.toml +10 -1
  4. pgsqlasync2fast_fastapi-0.3.1/src/pgsqlasync2fast_fastapi/__version__.py +1 -0
  5. pgsqlasync2fast_fastapi-0.3.1/src/pgsqlasync2fast_fastapi/skills/SKILL.md +70 -0
  6. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1/src/pgsqlasync2fast_fastapi.egg-info}/PKG-INFO +3 -1
  7. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi.egg-info/SOURCES.txt +1 -1
  8. pgsqlasync2fast_fastapi-0.3.0/docs/.env.example +0 -50
  9. pgsqlasync2fast_fastapi-0.3.0/src/pgsqlasync2fast_fastapi/__version__.py +0 -1
  10. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/LICENSE +0 -0
  11. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/MANIFEST.in +0 -0
  12. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/docs/seeder-format.md +0 -0
  13. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/dev/categories.json +0 -0
  14. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/dev/permissions.json +0 -0
  15. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/dev/roles.json +0 -0
  16. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/manifest.json +0 -0
  17. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/prod/categories.json +0 -0
  18. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/prod/permissions.json +0 -0
  19. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/examples/seeders/prod/roles.json +0 -0
  20. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/setup.cfg +0 -0
  21. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/__init__.py +0 -0
  22. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/connection.py +0 -0
  23. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/database.py +0 -0
  24. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/dependencies.py +0 -0
  25. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/seeder.py +0 -0
  26. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi/settings.py +0 -0
  27. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi.egg-info/dependency_links.txt +0 -0
  28. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi.egg-info/requires.txt +0 -0
  29. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/src/pgsqlasync2fast_fastapi.egg-info/top_level.txt +0 -0
  30. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/tests/test_completo.py +0 -0
  31. {pgsqlasync2fast_fastapi-0.3.0 → pgsqlasync2fast_fastapi-0.3.1}/tests/test_seeder.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pgsqlasync2fast-fastapi
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Simple and fast PostgreSQL async module for FastAPI with multi-database support
5
5
  Author-email: Angel Daniel Sanchez Castillo <angeldaniel.sanchezcastillo@gmail.com>
6
6
  License: MIT License
@@ -56,6 +56,8 @@ Dynamic: license-file
56
56
 
57
57
  Simple and fast PostgreSQL async module for FastAPI with multi-database support and automatic database creation.
58
58
 
59
+ > 📖 **Conventions reference**: this package follows the [2fast-handbook](https://github.com/AngelDanielSanchezCastillo/2fast-handbook) for ecosystem conventions (structure, versioning, README, commits, release).
60
+
59
61
  ## Features
60
62
 
61
63
  - ✅ **Multiple Database Connections**: Configure and manage multiple PostgreSQL databases
@@ -2,6 +2,8 @@
2
2
 
3
3
  Simple and fast PostgreSQL async module for FastAPI with multi-database support and automatic database creation.
4
4
 
5
+ > 📖 **Conventions reference**: this package follows the [2fast-handbook](https://github.com/AngelDanielSanchezCastillo/2fast-handbook) for ecosystem conventions (structure, versioning, README, commits, release).
6
+
5
7
  ## Features
6
8
 
7
9
  - ✅ **Multiple Database Connections**: Configure and manage multiple PostgreSQL databases
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pgsqlasync2fast-fastapi"
7
- version = "0.3.0"
7
+ dynamic = ["version"]
8
8
  description = "Simple and fast PostgreSQL async module for FastAPI with multi-database support"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -64,6 +64,15 @@ package-dir = {"" = "src"}
64
64
  where = ["src"]
65
65
  include = ["pgsqlasync2fast_fastapi*"]
66
66
 
67
+ # Single source of truth for the version: __version__.py
68
+ [tool.setuptools.dynamic]
69
+ version = {attr = "pgsqlasync2fast_fastapi.__version__.__version__"}
70
+
71
+ [tool.setuptools.package-data]
72
+ pgsqlasync2fast_fastapi = [
73
+ "skills/*.md",
74
+ ]
75
+
67
76
  [tool.pytest.ini_options]
68
77
  testpaths = ["tests"]
69
78
  python_files = ["test_*.py"]
@@ -0,0 +1 @@
1
+ __version__ = "0.3.1"
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: pgsqlasync2fast-fastapi
3
+ description: "Trigger: working on or with pgsqlasync2fast-fastapi. Multi-database async engine manager for FastAPI: DB_CONNECTIONS config, get_db_session deps, seeder orchestrator, tenant engines. Prevails over the 2fast-handbook base skill for this package."
4
+ license: MIT
5
+ metadata:
6
+ author: AngelDanielSanchezCastillo
7
+ version: "1.0"
8
+ ---
9
+
10
+ ## Purpose
11
+
12
+ Connection-management foundation of the 2fast stack: multiple PostgreSQL
13
+ engines/session factories keyed by connection name (`default`, `auth`,
14
+ `business`, `tenant_{id}`), lifecycle, and the generic seeder orchestrator.
15
+
16
+ ## Import quirk
17
+
18
+ - Dist `pgsqlasync2fast-fastapi` → import `pgsqlasync2fast_fastapi` (dash→underscore only).
19
+ - Two "default connection" paths DISAGREE: `get_db_session`/`get_db_engine` default `connection_name="default"` (literal string), while `DatabaseManager.get_engine`/`get_connection` fall back `None → config.default_connection`. Never rely on `"default"`: name your primary `default` or always pass an explicit name via `functools.partial` (oauth2fast pattern: `get_auth_session = partial(get_db_session, connection_name="auth")`).
20
+
21
+ ## Public API
22
+
23
+ - `get_manager(config=None)` — **global singleton**; honors a custom config only on its FIRST call. `get_db_manager` (FastAPI dep) always injects the module `settings`, so per-app config via the dep path is impossible.
24
+ - `get_db_engine(connection_name="default")`, `get_db_session(connection_name="default")` (yields session; commits on success, rolls back on exception, closes in finally).
25
+ - `startup_database()` — **NOT lazy**: eagerly creates and health-checks EVERY configured connection. README's "lazy loading" is wrong.
26
+ - `shutdown_database()` → `manager.close_all()` (disposes all engines).
27
+ - DB ops `database_exists/create_database/drop_database/list_databases` — ALL require a superuser connection (`is_superuser=True`; first configured one wins); use AUTOCOMMIT isolation.
28
+ - Seeder: `SeederConfig`, `register_seeder`, `seed_all`, `get_registered_seeders`, `SeederConflictError`.
29
+
30
+ ## Architecture
31
+
32
+ - `DatabaseSettings.connections: dict[str, DatabaseConnectionSettings]` — any lowercase name is a legal key (env `DB_CONNECTIONS__{NAME}__*`).
33
+ - Engine: `create_async_engine(url, echo, pool_size=5, max_overflow=10, pool_timeout=30, pool_recycle=3600, pool_pre_ping=True)` (pre_ping hard-coded). URL: `postgresql+asyncpg://user:pass@host:port/db`.
34
+ - Each engine has a parallel `async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)` (SQLModel session — supports BOTH `session.execute` and `session.exec`).
35
+ - `echo` resolution QUIRK: `conn.echo if conn.echo else global echo` — a connection-level `echo=False` cannot override a global `echo=True`.
36
+
37
+ ## Dynamic/tenant engines (private contract)
38
+
39
+ - There is **no public API to register an engine at runtime**. tenants2fast writes the manager's PRIVATE (`manager._engines`, `manager._session_makers`, `manager.config.connections`) directly. No LRU, no cap — dynamic engines accumulate unboundedly (N tenants × up to 15 connections each). Dispose idle tenant engines explicitly.
40
+ - `get_manager(config)` honors custom config only once; the FastAPI dep always passes module settings.
41
+
42
+ ## Wiring
43
+
44
+ ```python
45
+ from pgsqlasync2fast_fastapi import get_db_session, startup_database, shutdown_database
46
+ # startup(shutdown) events: await startup_database() / await shutdown_database()
47
+ session: AsyncSession = Depends(get_db_session) # or partial with connection_name
48
+ ```
49
+
50
+ Downstream imports (stable contracts): oauth2fast `get_db_session`→`partial(..., connection_name="auth")`; permissions2fast `SeederConfig, register_seeder`; tenants2fast `create_database, drop_database`, `connection.get_manager`, `settings.settings, DatabaseConnectionSettings`.
51
+
52
+ ## Seeder orchestrator
53
+
54
+ - `register_seeder` does registration-time **table-conflict detection** per connection (`SeederConflictError` if two seeders on the same connection share a manifest `tables` key).
55
+ - `seed_all(profile, package_filter=None)` sorts by `priority` (LOWER first). **Skips** registered seeders with `is_tenant_seeder=True` and no `seed_fn` (warns — tenant seeding must be driven by `seed_all_tenants`/the tenant package itself).
56
+ - Generic path: topological sort of `depends_on` (cycle → `SeedValidationError`), FK resolution `fk_field_mapping`/`fk_fields`/`rstrip('s')+'_id'`, insert **per row** with explicit `id` → idempotent (SELECT by id, skip if exists, commit per row).
57
+
58
+ ## Settings
59
+
60
+ `DatabaseSettings`, prefix `DB_`, nested `__`, `.env` from **process CWD**. Top: `DB_DEFAULT_CONNECTION` (default "default"), `DB_ECHO` (False). Per connection: `HOST, USERNAME, PASSWORD, DATABASE` (**all required** — import crashes otherwise), `PORT` (5432), `IS_SUPERUSER` (False), `POOL_SIZE` (5), `MAX_OVERFLOW` (10), `POOL_TIMEOUT` (30), `POOL_RECYCLE` (3600), `ECHO` (False). Missing `.env` does NOT crash at import — it yields an empty manager that fails on first `get_engine` (plus a Spanish warning).
61
+
62
+ ## Gotchas
63
+
64
+ - `create_database`/`drop_database` require a configured superuser connection.
65
+ - Engines are disposed only by `shutdown_database`/`close_all` — or by tenants2fast's `dispose_tenant_engine` for individual tenant engines; dropping a tenant DB without disposing first leaks connections.
66
+
67
+ ## Golden rule (inherited)
68
+
69
+ Follow the 2fast-handbook base skill for layout/versioning/naming/README/commits/release.
70
+ Local edits are fine; NEVER bump/publish on your own — prepare the exact command and hand it to the developer.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pgsqlasync2fast-fastapi
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Simple and fast PostgreSQL async module for FastAPI with multi-database support
5
5
  Author-email: Angel Daniel Sanchez Castillo <angeldaniel.sanchezcastillo@gmail.com>
6
6
  License: MIT License
@@ -56,6 +56,8 @@ Dynamic: license-file
56
56
 
57
57
  Simple and fast PostgreSQL async module for FastAPI with multi-database support and automatic database creation.
58
58
 
59
+ > 📖 **Conventions reference**: this package follows the [2fast-handbook](https://github.com/AngelDanielSanchezCastillo/2fast-handbook) for ecosystem conventions (structure, versioning, README, commits, release).
60
+
59
61
  ## Features
60
62
 
61
63
  - ✅ **Multiple Database Connections**: Configure and manage multiple PostgreSQL databases
@@ -2,7 +2,6 @@ LICENSE
2
2
  MANIFEST.in
3
3
  README.md
4
4
  pyproject.toml
5
- docs/.env.example
6
5
  docs/seeder-format.md
7
6
  examples/seeders/manifest.json
8
7
  examples/seeders/dev/categories.json
@@ -23,5 +22,6 @@ src/pgsqlasync2fast_fastapi.egg-info/SOURCES.txt
23
22
  src/pgsqlasync2fast_fastapi.egg-info/dependency_links.txt
24
23
  src/pgsqlasync2fast_fastapi.egg-info/requires.txt
25
24
  src/pgsqlasync2fast_fastapi.egg-info/top_level.txt
25
+ src/pgsqlasync2fast_fastapi/skills/SKILL.md
26
26
  tests/test_completo.py
27
27
  tests/test_seeder.py
@@ -1,50 +0,0 @@
1
- # ============================================
2
- # PostgreSQL Database Configuration
3
- # ============================================
4
-
5
- # ===== Connection DEFAULT (principal) =====
6
- # Esta es la conexión por defecto que se usará cuando no especifiques ninguna
7
- DB_CONNECTIONS__DEFAULT__HOST=localhost
8
- DB_CONNECTIONS__DEFAULT__PORT=5432
9
- DB_CONNECTIONS__DEFAULT__USERNAME=myuser
10
- DB_CONNECTIONS__DEFAULT__PASSWORD=mypassword
11
- DB_CONNECTIONS__DEFAULT__DATABASE=mydb
12
- DB_CONNECTIONS__DEFAULT__IS_SUPERUSER=false
13
-
14
- # Pool settings (opcional, estos son los valores por defecto)
15
- DB_CONNECTIONS__DEFAULT__POOL_SIZE=5
16
- DB_CONNECTIONS__DEFAULT__MAX_OVERFLOW=10
17
- DB_CONNECTIONS__DEFAULT__POOL_TIMEOUT=30
18
- DB_CONNECTIONS__DEFAULT__POOL_RECYCLE=3600
19
-
20
- # Echo mode para esta conexión (opcional)
21
- DB_CONNECTIONS__DEFAULT__ECHO=false
22
-
23
- # ===== Connection BUSINESS (ejemplo de segunda conexión) =====
24
- # Para usar esta conexión, especifica connection_name="business" en tus dependencias
25
- DB_CONNECTIONS__BUSINESS__HOST=localhost
26
- DB_CONNECTIONS__BUSINESS__PORT=5432
27
- DB_CONNECTIONS__BUSINESS__USERNAME=business_user
28
- DB_CONNECTIONS__BUSINESS__PASSWORD=business_password
29
- DB_CONNECTIONS__BUSINESS__DATABASE=business_db
30
- DB_CONNECTIONS__BUSINESS__IS_SUPERUSER=false
31
-
32
- # ===== Connection ADMIN (ejemplo con superusuario) =====
33
- # Esta conexión tiene privilegios de superusuario para crear/eliminar bases de datos
34
- DB_CONNECTIONS__ADMIN__HOST=localhost
35
- DB_CONNECTIONS__ADMIN__PORT=5432
36
- DB_CONNECTIONS__ADMIN__USERNAME=postgres
37
- DB_CONNECTIONS__ADMIN__PASSWORD=postgres_password
38
- DB_CONNECTIONS__ADMIN__DATABASE=postgres
39
- DB_CONNECTIONS__ADMIN__IS_SUPERUSER=true
40
-
41
- # ============================================
42
- # General Settings
43
- # ============================================
44
-
45
- # Conexión por defecto cuando no se especifica ninguna
46
- # Opciones: "default", "business", "admin", o cualquier otra que hayas configurado
47
- DB_DEFAULT_CONNECTION=default
48
-
49
- # Echo mode global (puede ser sobrescrito por cada conexión)
50
- DB_ECHO=false
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"