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语句, ...
随机推荐
- lua定义一个简单的类
classA.lua: classA = { a = , b = , --__index = classA; }; classA.__index = classA; function classA:n ...
- javascript: parse JSON
$.get("/intra/do/sequence_has_codonList.pl",function(data){ data = JSON.parse(data); // ar ...
- 常用SQL总结
数据库知识总结一.数据库服务器设置1,查看数据库服务器编码 show variables like 'character%';2,设置数据库服务器编码 set character_set_ ...
- python 列表排序
转自http://www.iplaypython.com/jinjie/jj114.html reverse()方法 将列表中元素反转排序,比如下面这样>>> x = [1,5,2, ...
- nodejs学习笔记二:解析express框架项目文件
上一章介绍了如何去创建一个express框架的工程项目,这章介绍一下express框架下的文件和用法解析,上一张我们创建的工程项目结构图如下: models是不属于原工程项目结构,为了实现数据模型后添 ...
- ML-分类与逻辑回归
布尔分类(binary classification)问题: 训练集:$S=\{(x^{(i)}, y^{(i)})\}$ 输入:特征向量$x$ 期望输出:$y\in\{0, 1\}$ 这里使用的假设 ...
- 移动APP项目优化
团队计划:设计一款给用户提供就医帮助的安卓APP. 项目计划:两个月内团队成员共同开发完成此款APP,此款APP提供预约挂号,名医名院咨询,就医导航等功能. 角色职责:负责交互设计.UI界面设计.1. ...
- Fragment全解析系列(一):那些年踩过的坑
开始之前 最新版知乎,单Activity多Fragment的架构,响应可以说非常"丝滑",非要说缺点的话,就是没有转场动画,并且转场会有类似闪屏现象.我猜测可能和Fragment转 ...
- Other linker flags
-ObjC:加了这个参数后,链接器就会把静态库中所有的Objective-C类和分类都加载到最后的可执行文件中-all_load:会让链接器把所有找到的目标文件都加载到可执行文件中,但是千万不要随便使 ...
- MySQL 添加列, 修改列, 删除列
ALTER TABLE:添加,修改,删除表的列,约束等表的定义. 查看列:desc 表名; 查看数据库创建语句: show create database 数据库名: 查看创建表的语句: show c ...