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/

Object Relational Tutorial 对象关系教程的更多相关文章

  1. Object/Relational Mapping 数学关系 反面向对象

    [hibernate ORM 是对象关系映射框架 事实上的持久化存储引擎] http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/ ...

  2. ORM详解,ORM Object relation mapping (对象关系映射)

  3. Object Relational Mapping框架之Hibernate

    hibernate框架简介: hibernate框架就是开发中在持久层中应用居多的ORM框架,它对JDBC做了轻量级的封装. (百度介绍,感觉不错) 什么是ORM:Object Relational ...

  4. Flask-SQLAlchemy 配置,处理对象-关系,一对多,多对多

      ORM(Object Relational Mapper) 对象关系映射.指将面对对象得方法映射到数据库中的关系对象中. Flask-SQLAlchemy是一个Flask扩展,能够支持多种数据库后 ...

  5. c++对象关系映射(ORM)框架

    ORM(Object Relational Mapping, 对象关系映射),用来将基于对象的数据结构映射到SQL的数据结构中,即将基于对象的数据映射到关系表中的字段,然后我们可以通过对象提供的接口来 ...

  6. SQLAlchemy-对象关系教程ORM-连接,子查询

    对象关系教程ORM-连接 一:内连接 方法一: for u, a in session.query(User, Address).\ filter(User.id==Address.user_id). ...

  7. SQLAlchemy-对象关系教程ORM-query

    一:对象关系教程查询 一个 Query创建对象时使用 Session的query()方法 .此函数接受一个变量数量的参数,可以是任何类和class-instrumented描述符的组合. Query返 ...

  8. 一:ORM关系对象映射(Object Relational Mapping,简称ORM)

    狼来的日子里! 奋发博取 10)django-ORM(创建,字段类型,字段参数) 一:ORM关系对象映射(Object Relational Mapping,简称ORM) ORM分两种: DB fir ...

  9. 解析大型.NET ERP系统数据访问 对象关系映射框架LLBL Gen Pro

    LLBL Gen Pro是一个为.NET开发人员设计的的对象关系映射(ORM)框架,与NHibernate,Entity Framework等框架一样,通过实体与数据表的映射,实现关系数据库持久化. ...

随机推荐

  1. js 从一个函数中传递值到另一个函数

    一个函数的调用大家都会用 我今天在调接口的时候突然发现需要引用个另一个函数中拿到的值 举个栗子 刚开始 我是这样调用的 alert弹出的是 hello world . 但是我a函数内部还有一个函数 画 ...

  2. windows 10下通过python3.6成功搭建jupyter 服务器

    最近通过python学习爬虫技术,发现一个工具jupyter notebook很不错,该工具明显优势通过浏览器可以输入多行python代码,支持在线运行以及运行结果保存功能,在线验证python小模块 ...

  3. 格式化输出io:format的奇技淫巧

    格式化输出io:format是我接触Erlang使用的第一个库函数(io:format("Hello World")),随着学习的深入,它也是我debug优先选择最简单直接的工具. ...

  4. Ansible自动化运维工具-上

    [Ansible特点] 1)Ansible与saltstack均是基于Python语言开发的 2)安装使用简单,基于不同插件和模块实现各种软件,平台,版本的管理以及支持虚拟容器多层级的部署 3)不需要 ...

  5. JDBC学习笔记 day1

    JDBC的基本概念: JDBC就是java database connectivity,即java数据库连接. JDBC主要完成的几个任务分别为 与数据库建立一个连接 向数据库发送SQL语句 处理数据 ...

  6. IDE-Android Studio -FAQ-使用习惯(不断更新 欢迎留言)

    摘要: 从ecplise工具切换到android studio后遇到了很多问题,起初亦非常痛苦,城墙内外阅博无数才得以解决.所以把当时遇到的问题记录下来,方便后来人学习. 另如果有遇到未纪录的问题欢迎 ...

  7. zoj 3950 how many nines

    https://vjudge.net/problem/ZOJ-3950 题意: 给出两个日期,计算从第一个日期开始到第二个日期,每一天的日期中的9加起来一共有多少个. 思路: 看题解补的题.首先看这题 ...

  8. 广度优先(bfs)和深度优先搜索(dfs)的应用实例

    广度优先搜索应用举例:计算网络跳数 图结构在解决许多网络相关的问题时直到了重要的作用. 比如,用来确定在互联网中从一个结点到另一个结点(一个网络到其他网络的网关)的最佳路径.一种建模方法是采用无向图, ...

  9. Thymeleaf3语法详解和实战

    Thymeleaf3语法详解 Thymeleaf是Spring boot推荐使用的模版引擎,除此之外常见的还有Freemarker和Jsp.Jsp应该是我们最早接触的模版引擎.而Freemarker工 ...

  10. Unity3D input.GetAxis

    input.GetAxis用法:(GetAxis("Mouse X"),GetAxis("Mouse Y"),GetAxis("Mouse Scrol ...