Python’s SQLAlchemy vs Other ORMs[转发 7] 比较结论
Comparison Between Python ORMs
For each Python ORM presented in this article, we are going to list their pros and cons here:
SQLObject
Pros:
- Adopted the easy-to-understand ActiveRecord pattern
- A relatively small codebase
Cons:
- Naming of methods and classes follow Java's camelCase style
- Does not support database sessions to isolate unit of work
Storm
Pros:
- A clean and lightweight API leading to short learning curve and long-term maintainability
- Does not need special class constructors, nor imperative base classes
Cons:
- Forcing the programmer to write manual table-creation DDL statements instead of automatically deriving it from the model class
- Contributors of Storm have to give their contributions' copyrights to Canonical Ltd.
Django's ORM
Pros:
- Easy-to-use with a short learning curve
- Tightly integrated with Django to make it the de-factor standard when dealing with databases in Django
Cons:
- Does not handle complex queries very well; forcing the developer to go back to raw SQL
- Tightly integrated with Django; making it hard to use outside of a Django context
peewee
Pros:
- A Django-ish API; making it easy-to-use
- A lightweight implementation; making it easy to integrate with any web framework
Cons:
- Does not support automatic schema migrations
- Many-to-Many queries are not intuitive to write
SQLAlchemy
Pros:
- Enterprise-level APIs; making the code robust and adaptable
- Flexible design; making it painless to write complex queries
Cons:
- The Unit-of-work concept is not common
- A heavyweight API; leading to a long learning curve
PonyORM
Pros:
- A very convenient syntax for writing queries
- Automatic query optimization
- Simplified setup and usage
Cons:
- Not designed to process hundreds of thousands or millions of records simultaneously
Summary and Tips
Compared to other ORMs, SQLAlchemy stands out in its focus on the unit-of-work concept which is prevalent whenever you write SQLAlchemy code. The DBSession concept might be hard to understand and use correctly initially, but later you will appreciate the additional complexity which reduces accidental database commit-timing-related bugs to almost zero. Dealing with multiple databases in SQLAlchemy can be tricky since each DB session is confined to one database connection. However, this kind of limitation is actually a good thing since it forces you to think hard about the interaction between multiple databases and make it easier to debug database interaction code.
In the future articles, we are going to fully explore more advanced use cases of SQLAlchemy to truly grasp its immensely powerful APIs.
Python’s SQLAlchemy vs Other ORMs[转发 7] 比较结论的更多相关文章
- Python’s SQLAlchemy vs Other ORMs[转发 6]SQLAlchemy
SQLAlchemy SQLAlchemy is an open source SQL toolkit and ORM for the Python programming language rele ...
- Python’s SQLAlchemy vs Other ORMs[转发 0]
原文地址:http://pythoncentral.io/sqlalchemy-vs-orms/ Overview of Python ORMs As a wonderful language, Py ...
- Python’s SQLAlchemy vs Other ORMs[转发 3]Django's ORM
Django's ORM Django is a free and open source web application framework whose ORM is built tightly i ...
- Python’s SQLAlchemy vs Other ORMs[转发 2]Storm
Storm Storm is a Python ORM that maps objects between one or more databases and Python. It allows de ...
- Python’s SQLAlchemy vs Other ORMs[转发 1]SQLObject
SQLObject SQLObject is a Python ORM that maps objects between a SQL database and Python. It is becom ...
- Python’s SQLAlchemy vs Other ORMs[转发 4]peewee
peewee peewee is a small, expressive ORM. Compared to other ORMs, peewee focuses on the principal of ...
- Python’s SQLAlchemy vs Other ORMs[转发 5] PonyORM
PonyORM PonyORM allows you to query the database using Python generators. These generators are trans ...
- 基于Python的SQLAlchemy的操作
安装 在Python使用SQLAlchemy的首要前提是安装相应的模块,当然作为python的优势,可以到python安装目录下的scripts下,同时按住shift+加上鼠标左键,从而在菜单中打开命 ...
- SQLAlchemy(1) -- Python的SQLAlchemy和ORM
Python的SQLAlchemy和ORM(object-relational mapping:对象关系映射) web编程中有一项常规任务就是创建一个有效的后台数据库.以前,程序员是通过写sql语句, ...
随机推荐
- expected identifier before numeric constant
症状: expected identifier before numeric constantexpected `}' before numeric constantexpected unqualif ...
- Dedecms 图片加上Alt或Title等属性写法
代码如下:$this->Fields['typename'] = $this->TypeLink->TypeInfos['typename']; SetSysEnv($this-&g ...
- poj3253 Fence Repair
http://poj.org/problem?id=3253 Farmer John wants to repair a small length of the fence around the pa ...
- 关于webrtc视频会议的解决方案
以我的经验来看视频会议分两种模式:网状模型,星型 1.网状模型 所谓的网状模型就是参加会议的人中每两个人建立一个点对点的连接. 比如:一个会议室有三个人A,B,C 基于网络模型就需要这样: 1.A和B ...
- 总结一下今天做的unity面试题(一):刚体的点击事件
按照需求,由于要模拟丧尸被击中的效果,不能使用CharactorControll组件,只能使用rigidbody组件. 首先在场景上摆好僵尸和相机的位置,这里就不给相机加脚本了,直接固定住. 然后给丧 ...
- Android应用的安全的攻防之战
一.前言 在前两篇破解的文章中,我们介绍了如何使用动态调试来破解apk,一个是通过调试smali源码,一个是通过调试so代码来进行代码的跟踪破解,那么今天我们就这两篇文章的破解方法,来看看Androi ...
- 一个简单的物料防错DEMO
前言 快2个月没写过博客了,就算是记流水账似的文章都没时间写,主要是太忙了:太多的bug要修复.太多由于bug引起的异常问题要解决.还有新的项目要开发,不忙怎么行呢?最近利用业余时间在鼓捣一个PDA的 ...
- hdu 5506 GT and set dfs+bitset优化
GT and set Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Probl ...
- get传中文参数乱码解决方法
通常我们前端不同页面之间传参数用得最多的方法就是get方法:在url后面加上参数.例如:www.test.com?id=1&name=hello. 英文和字母很好处理,但是如果有的参数值为中文 ...
- 转-阿里云CentOS Linux服务器上用postfix搭建邮件服务器
http://www.cnblogs.com/dudu/archive/2012/12/12/linux-postfix-mailserver.html 注:本文的邮件服务器只用于发送邮件,也就是ST ...