graph LR
Database_Connectivity_Dialects["Database Connectivity & Dialects"]
SQL_Expression_Statement_Layer["SQL Expression & Statement Layer"]
Schema_Metadata_Management["Schema & Metadata Management"]
ORM_Core_Unit_of_Work["ORM Core & Unit of Work"]
ORM_Mapping_Querying["ORM Mapping & Querying"]
Event_Utility_System["Event & Utility System"]
Database_Connectivity_Dialects -- "manages connections for" --> ORM_Core_Unit_of_Work
Database_Connectivity_Dialects -- "provides dialect support to" --> SQL_Expression_Statement_Layer
SQL_Expression_Statement_Layer -- "compiles for" --> Database_Connectivity_Dialects
SQL_Expression_Statement_Layer -- "is built upon" --> Schema_Metadata_Management
SQL_Expression_Statement_Layer -- "generates queries for" --> ORM_Mapping_Querying
Schema_Metadata_Management -- "defines structures for" --> SQL_Expression_Statement_Layer
Schema_Metadata_Management -- "is used by" --> ORM_Mapping_Querying
ORM_Core_Unit_of_Work -- "orchestrates persistence via" --> Database_Connectivity_Dialects
ORM_Core_Unit_of_Work -- "leverages" --> ORM_Mapping_Querying
ORM_Mapping_Querying -- "translates to" --> SQL_Expression_Statement_Layer
Event_Utility_System -- "provides cross-cutting services to" --> Database_Connectivity_Dialects
Event_Utility_System -- "provides cross-cutting services to" --> SQL_Expression_Statement_Layer
Event_Utility_System -- "provides cross-cutting services to" --> Schema_Metadata_Management
Event_Utility_System -- "provides cross-cutting services to" --> ORM_Core_Unit_of_Work
Event_Utility_System -- "provides cross-cutting services to" --> ORM_Mapping_Querying
click Database_Connectivity_Dialects href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/Database Connectivity & Dialects.md" "Details"
click SQL_Expression_Statement_Layer href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/SQL Expression & Statement Layer.md" "Details"
click Schema_Metadata_Management href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/Schema & Metadata Management.md" "Details"
click ORM_Core_Unit_of_Work href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/ORM Core & Unit of Work.md" "Details"
click ORM_Mapping_Querying href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/ORM Mapping & Querying.md" "Details"
click Event_Utility_System href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/sqlalchemy/Event & Utility System.md" "Details"
The SQLAlchemy architecture is designed to provide a comprehensive and flexible toolkit for interacting with relational databases, offering both a low-level SQL Expression Language and a high-level Object Relational Mapper (ORM). The main flow involves establishing database connections, constructing SQL statements (either directly or via ORM objects), compiling these statements for specific database dialects, executing them, and then processing the results, often mapping them back to Python objects. The system is highly modular, allowing components to be used independently or together, and includes an extensible event system for custom logic injection.
Manages fundamental database connectivity, including creating and managing database connections, handling connection pools, parsing database URLs, and providing asynchronous interfaces for these operations. It also encapsulates dialect-specific implementations for various database systems, handling their unique SQL syntax and data types.
Related Classes/Methods:
sqlalchemy.engine.base.Engine(2919:3302)sqlalchemy.engine.base.Connection(88:2462)sqlalchemy.engine.create.create_engine(49:85)sqlalchemy.engine.url.URL(46:836)sqlalchemy.pool.base.Pool(155:468)sqlalchemy.ext.asyncio.engine.AsyncEngine(1001:1328)sqlalchemy.ext.asyncio.engine.AsyncConnection(192:984)sqlalchemy.dialects.sqlite.base.SQLiteDialect(2028:2917)sqlalchemy.engine.default.DefaultDialect(122:1177)
Provides the foundational building blocks for constructing abstract SQL expressions (e.g., columns, literals, operators) and high-level SQL statements (SELECT, INSERT, UPDATE, DELETE), including complex constructs like joins and subqueries. It also handles the translation of these abstract constructs into concrete, dialect-specific SQL strings for execution, and manages SQLAlchemy's internal representation of SQL data types.
Related Classes/Methods:
sqlalchemy.sql.elements.ColumnElement(1244:1869)sqlalchemy.sql.elements.BinaryExpression(3890:4039)sqlalchemy.sql.elements.TextClause(2257:2637)sqlalchemy.sql.elements.BindParameter(1946:2236)sqlalchemy.sql.elements.ClauseList(2762:2867)sqlalchemy.sql.selectable.Select(5223:6777)sqlalchemy.sql.selectable.TableClause(3071:3227)sqlalchemy.sql.selectable.Join(1230:1661)sqlalchemy.sql.dml.Insert(1194:1462)sqlalchemy.sql.dml.Update(1568:1762)sqlalchemy.sql.dml.Delete(1777:1914)sqlalchemy.sql.selectable.CTE(2107:2301)sqlalchemy.sql.compiler.SQLCompiler(1053:6533)sqlalchemy.sql.compiler.DDLCompiler(6647:7204)sqlalchemy.sql.compiler.TypeCompiler(966:985)sqlalchemy.sql.compiler.IdentifierPreparer(7437:7920)sqlalchemy.sql.type_api.TypeEngine(118:1098)sqlalchemy.sql.type_api.TypeDecorator(1508:2294)sqlalchemy.sql.sqltypes.String(177:269)sqlalchemy.sql.sqltypes.Numeric(511:642)sqlalchemy.sql.sqltypes.DateTime(791:853)
Defines and manages database schema objects such as tables, columns, and constraints. It provides functionality for generating and executing Data Definition Language (DDL) statements (CREATE, ALTER, DROP), and includes tools for introspecting existing database schemas.
Related Classes/Methods:
sqlalchemy.sql.schema.Table(317:1488)sqlalchemy.sql.schema.Column(1491:2702)sqlalchemy.sql.schema.MetaData(5467:6019)sqlalchemy.sql.schema.ForeignKey(2755:3351)sqlalchemy.sql.schema.PrimaryKeyConstraint(4968:5210)sqlalchemy.sql.schema.UniqueConstraint(5213:5222)sqlalchemy.sql.schema.CheckConstraint(4544:4652)sqlalchemy.sql.schema.Index(5225:5436)sqlalchemy.sql.ddl.SchemaGenerator(912:1063)sqlalchemy.sql.ddl.SchemaDropper(1066:1235)sqlalchemy.engine.reflection.Inspector(182:2037)
The central component for Object Relational Mapping, managing the lifecycle of persistent objects, providing a unit of work for database operations, and maintaining an identity map for loaded objects. It orchestrates the process of saving, updating, and deleting ORM objects to the database, ensuring transactional integrity and dependency ordering.
Related Classes/Methods:
sqlalchemy.orm.session.Session(1446:4975)sqlalchemy.orm.session.SessionTransaction(839:1437)sqlalchemy.orm.session.sessionmaker(4981:5210)sqlalchemy.orm.identity.IdentityMap(37:123)sqlalchemy.orm.state.InstanceState(105:1015)sqlalchemy.orm.unitofwork.UOWTransaction(157:489)sqlalchemy.orm.persistence._save_obj(40:120)sqlalchemy.orm.bulk_persistence._bulk_insert(77:87)
Defines how Python classes are mapped to database tables, including inheritance strategies and the declarative base system for model definition. It provides the object-oriented interface for constructing and executing database queries, translating them into SQL statements and loading results into mapped objects, and manages object attributes and relationships.
Related Classes/Methods:
sqlalchemy.orm.mapper.Mapper(166:4055)sqlalchemy.orm.decl_api.DeclarativeBase(629:839)sqlalchemy.orm.decl_api.registry(1106:1808)sqlalchemy.orm.query.Query(164:3411)sqlalchemy.orm.attributes.InstrumentedAttribute(510:570)sqlalchemy.orm.relationships.RelationshipProperty(344:2306)sqlalchemy.orm.loading.instances(80:300)sqlalchemy.orm.strategy_options.Load(965:1328)
A cross-cutting component providing a flexible mechanism for registering and dispatching events throughout SQLAlchemy's lifecycle, allowing users to inject custom logic. It also includes a collection of general-purpose helper functions, data structures, and compatibility layers used across the entire library, as well as introspection tools for examining internal structures.
Related Classes/Methods:
sqlalchemy.event.api.listen(39:121)sqlalchemy.event.registry._EventKey(219:390)sqlalchemy.event.base._Dispatch(92:215)sqlalchemy.util.langhelpers.warn(1886:1896)sqlalchemy.util._collections.LRUCache(458:560)sqlalchemy.util.concurrency.await_(145:169)sqlalchemy.util.deprecations.warn_deprecated(55:60)sqlalchemy.inspection.inspect(90:92)