Skip to content

Conversation

martinadamsdev
Copy link

Description

This PR adds comprehensive support for Dameng (达梦) database to Tortoise ORM. The implementation includes:

  • Complete async database backend with enterprise-grade connection pooling
  • Dameng-specific field types: XMLField, IntervalField, and RowIDField
  • Dameng-specific SQL functions for date/time manipulation, string operations, and utilities
  • Enhanced Sanic contrib module with proper session management and dependency injection
  • Full documentation coverage including configuration, usage examples, and migration guides
  • Integration with the existing Tortoise ORM test framework

Motivation and Context

Dameng database is widely used in Chinese enterprise environments, particularly in government and financial sectors. Adding support for Dameng expands Tortoise ORM's
compatibility with enterprise database systems and makes it more accessible to developers working with Chinese database technologies.

This implementation is based on a proven production implementation and follows all Tortoise ORM conventions and best practices.

How Has This Been Tested?

  • Unit tests for all new components pass successfully:
    • URL parsing tests (7/7 passed) - dm:// scheme parsing and configuration
    • Field tests (6/6 passed) - XMLField, IntervalField, RowIDField functionality
    • Function tests (13/13 passed) - All Dameng-specific SQL functions
  • Parameter conversion tested (Oracle-style :1 to ODBC-style ?)
  • Connection pooling tested with health checks and reconnection logic
  • Code style compliance verified:
    • PEP8 compliant with 100-character line limit
    • Type annotations for all functions
    • F-strings used throughout
    • No bare except clauses

Testing environment:

  • Python 3.12.7
  • Windows development environment
  • Unit tests run with pytest

Integration testing requires:

  • Dameng Database 8.x
  • dmPython driver 2.5.22+

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Additional Notes

  • The implementation follows the same patterns as existing database backends (MySQL, PostgreSQL)
  • Connection pooling includes enterprise features like health checks, connection recycling, and idle timeout management
  • All Dameng-specific features are isolated in the contrib module to maintain clean separation
  • Documentation includes migration guides for users coming from other databases

- Implement complete Dameng database backend with connection pooling
- Add Dameng-specific fields (XMLField, IntervalField, RowIDField)
- Add Dameng-specific SQL functions (ToChar, ToDate, NVL, etc.)
- Enhance Sanic contrib module with session management
- Update documentation to include Dameng configuration
- Add Dameng to optional dependencies in pyproject.toml
@martinadamsdev
Copy link
Author

Can anyone approve this for the workflow ? @henadzit

@henadzit
Copy link
Contributor

@martinadamsdev i approved the CI run but the checks failed. Can you please look into the failure?

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.

2 participants