Skip to content

feat: implement multi-database support and routing#41

Merged
Einswilli merged 10 commits intoAllDotPy:masterfrom
Einswilli:fields_lookups
Apr 9, 2026
Merged

feat: implement multi-database support and routing#41
Einswilli merged 10 commits intoAllDotPy:masterfrom
Einswilli:fields_lookups

Conversation

@Einswilli
Copy link
Copy Markdown
Contributor

This PR introduces comprehensive multi-database support to the Ryx ORM, allowing users to route queries and transactions across multiple database pools.

Key Changes

  • Core Infrastructure: Replaced the global connection pool with a PoolRegistry to manage multiple named database aliases.
  • Flexible Routing: Implemented a multi-layered routing system with the following priority:
    1. Explicit routing via .using(alias) on QuerySets and Managers.
    2. Dynamic routing via a configurable BaseRouter.
    3. Model-level defaults via Model.Meta.database.
    4. Fallback to the 'default' database.
  • Multi-DB Transactions:
    • Added alias support to Ryx.transaction().
    • Implemented smart nesting: creates a SAVEPOINT when nesting on the same database, and a new independent transaction when switching databases.
  • Compatibility: Maintained backward compatibility by allowing ryx_core.setup() to accept both a single URL string and a dictionary of aliases.
  • Documentation: Added a new "Multi-Database Support" guide to the advanced documentation section.

Verification

  • Verified via integration tests covering explicit, meta, and dynamic routing.
  • Validated transaction behavior across multiple in-memory SQLite pools.

@Einswilli Einswilli merged commit dfbc44e into AllDotPy:master Apr 9, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant