zoukankan      html  css  js  c++  java
  • Object Relational Tutorial 对象关系教程

    The SQLAlchemy Object Relational Mapper presents a method of associating user-defined Python classes with database tables, and instances of those classes (objects) with rows in their corresponding tables. It includes a system that transparently synchronizes all changes in state between objects and their related rows, called a unit of work, as well as a system for expressing database queries in terms of the user defined classes and their defined relationships between each other.

    The ORM is in contrast to the SQLAlchemy Expression Language, upon which the ORM is constructed. Whereas the SQL Expression Language, introduced in SQL Expression Language Tutorial, presents a system of representing the primitive constructs of the relational database directly without opinion, the ORM presents a high level and abstracted pattern of usage, which itself is an example of applied usage of the Expression Language.

    While there is overlap among the usage patterns of the ORM and the Expression Language, the similarities are more superficial than they may at first appear. One approaches the structure and content of data from the perspective of a user-defined domain model which is transparently persisted and refreshed from its underlying storage model. The other approaches it from the perspective of literal schema and SQL expression representations which are explicitly composed into messages consumed individually by the database.

    A successful application may be constructed using the Object Relational Mapper exclusively. In advanced situations, an application constructed with the ORM may make occasional usage of the Expression Language directly in certain areas where specific database interactions are required.

    The following tutorial is in doctest format, meaning each >>> line represents something you can type at a Python command prompt, and the following text represents the expected return value.

    SQLAlchemy对象关系映射器提供了一种将用户定义的Python类与数据库表相关联的方法,以及在对应表中具有行的那些类(对象)的实例。它包括一个系统,可以透明地同步对象与其相关行之间的状态的所有更改,称为工作单元,以及根据用户定义的类及其彼此之间定义的关系来表达数据库查询的系统。

    ORM与构建ORM的SQLAlchemy表达式语言形成对比。而在SQL表达语言教程中引入的SQL表达式语言提供了一种直接表示关系数据库的原始构造的系统,而ORM呈现出高级和抽象的使用模式,本身就是应用程序的使用示例表达语言。

    虽然ORM和表达语言的使用模式之间存在重叠,但是相似之处比起初显示的更为肤浅。从用户定义的域模型的角度来看,数据的结构和内容从透明地持久化并从其底层存储模型刷新。另一个从文字模式和SQL表达式表达的角度来看待,这些表达式被明确地组合成数据库单独消费的消息。

    可以使用对象关系映射器专门构建成功的应用程序。在高级情况下,使用ORM构建的应用程序可能会在需要特定数据库交互的某些区域中偶尔使用表达式语言。

    以下教程采用doctest格式,这意味着每行>>>行表示可以在Python命令提示符下键入的内容,下面的文本表示预期的返回值。

    http://docs.sqlalchemy.org/en/latest/orm/tutorial.html

    http://www.buluo360.com/

  • 相关阅读:
    websocket初体验(能传文字和图片)
    展开折叠效果 height未知 transition无效
    微信小程序自定义键盘
    微信小程序 selectComponent 值为null
    css 斜线 animation
    【转】怎样在ubuntu12.04下创建一个启动器
    以ontouch为例说明android事件发送机制
    谈谈移动应用设计——从一个普通开发者的角度
    Launch error: Failed to connect to remote VM. Connection refused.的解决办法
    Beyond compare代码比较工具。
  • 原文地址:https://www.cnblogs.com/tensorflownews/p/7451902.html
Copyright © 2011-2022 走看看