Sqlalchemy 简明教程
SQLAlchemy Core – Expression Language
SQLAlchemy 核心包括 SQL rendering engine, DBAPI integration, transaction integration 和 schema description services 。SQLAlchemy 核心使用 SQL 表达式语言,提供 schema-centric usage 范式,而 SQLAlchemy ORM 则是 domain-centric mode of usage 。
SQLAlchemy core includes SQL rendering engine, DBAPI integration, transaction integration, and schema description services. SQLAlchemy core uses SQL Expression Language that provides a schema-centric usage paradigm whereas SQLAlchemy ORM is a domain-centric mode of usage.
SQL 表达式语言呈现了一个使用 Python 构造来表示关系数据库结构和表达式的系统。它呈现了一个系统来直接表示关系数据库的原始构造,这不同于 ORM,ORM 呈现了一个高级的、抽象化的用法模式,它本身就是对表达式语言应用用法的示例。
The SQL Expression Language presents a system of representing relational database structures and expressions using Python constructs. It presents a system of representing the primitive constructs of the relational database directly without opinion, which is in contrast to ORM that presents a high level and abstracted pattern of usage, which itself is an example of applied usage of the Expression Language.
表达式语言是 SQLAlchemy 的核心组件之一。它允许程序员在 Python 代码中指定 SQL 语句,并直接将其用于更加复杂的查询。表达式语言不依赖于后端,并且全面涵盖了原始 SQL 的各个方面。它比 SQLAlchemy 中的任何其他组件都更接近原始 SQL。
Expression Language is one of the core components of SQLAlchemy. It allows the programmer to specify SQL statements in Python code and use it directly in more complex queries. Expression language is independent of backend and comprehensively covers every aspect of raw SQL. It is closer to raw SQL than any other component in SQLAlchemy.
表达式语言直接表示关系数据库的原始构造。由于 ORM 基于表达式语言之上,因此典型的 Python 数据库应用程序可能重叠使用两者的用法。该应用程序可以单独使用表达式语言,尽管它必须定义自己的系统,将应用程序概念转换为各个数据库查询。
Expression Language represents the primitive constructs of the relational database directly. Because the ORM is based on top of Expression language, a typical Python database application may have overlapped use of both. The application may use expression language alone, though it has to define its own system of translating application concepts into individual database queries.
表达式语言的语句将由 SQLAlchemy 引擎转换为相应的原始 SQL 查询。现在,我们将学习如何创建引擎并借助于它执行各种 SQL 查询。
Statements of Expression language will be translated into corresponding raw SQL queries by SQLAlchemy engine. We shall now learn how to create the engine and execute various SQL queries with its help.