graph LR
Database_Wrapper["Database Wrapper"]
Database_Operations["Database Operations"]
Schema_Editor["Schema Editor"]
Database_Introspection["Database Introspection"]
Database_Client["Database Client"]
Specific_Backend["Specific Backend"]
Unclassified["Unclassified"]
Database_Wrapper -- "Delegates SQL Generation" --> Database_Operations
Database_Wrapper -- "Delegates Schema Manipulation" --> Schema_Editor
Specific_Backend -- "Provides concrete implementation for" --> Database_Wrapper
Specific_Backend -- "Provides concrete implementation for" --> Database_Operations
Specific_Backend -- "Provides concrete implementation for" --> Schema_Editor
Specific_Backend -- "Provides concrete implementation for" --> Database_Introspection
Specific_Backend -- "Provides concrete implementation for" --> Database_Client
The Django database backend subsystem is designed around a set of abstract base classes that define a common interface for database operations. Each supported database engine provides a concrete implementation of these classes in a specific backend package. The BaseDatabaseWrapper acts as the central coordinator, aggregating functionality from other specialized components like BaseDatabaseOperations for SQL generation, BaseDatabaseSchemaEditor for migrations, BaseDatabaseIntrospection for schema discovery, and BaseDatabaseClient for command-line shell integration. This architecture allows the Django ORM to work seamlessly across different databases by abstracting away engine-specific details.
The primary facade for all database interactions. It manages connections, transactions, and cursors, delegating database-specific operations to other components. It is the main entry point for the ORM.
Related Classes/Methods:
Responsible for generating database-specific SQL syntax. It handles tasks like quoting names, formatting data types for queries, and constructing SQL clauses unique to a particular database engine.
Related Classes/Methods:
Manages Data Definition Language (DDL). It provides the logic to create, alter, and delete tables, columns, and constraints, forming the core engine for the Django migration framework.
Related Classes/Methods:
Provides metadata about the database schema. It is used to examine existing tables, columns, indexes, and relations, primarily serving the inspectdb management command.
Related Classes/Methods:
Encapsulates the logic for interacting with the database's native command-line client. This component is used by the dbshell management command to provide direct shell access.
Related Classes/Methods:
A concrete implementation of the abstract base components for a specific database (e.g., PostgreSQL, MySQL). It inherits from the base classes and provides the actual implementation logic.
Related Classes/Methods:
django.db.backends.postgresql.base.DatabaseWrapper:98-556django.db.backends.mysql.base.DatabaseWrapper:103-443
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
Related Classes/Methods: None