Comparison Between Python ORMs

For each Python ORM presented in this article, we are going to list their pros and cons here:

SQLObject

Pros:

  1. Adopted the easy-to-understand ActiveRecord pattern
  2. A relatively small codebase

Cons:

  1. Naming of methods and classes follow Java's camelCase style
  2. Does not support database sessions to isolate unit of work

Storm

Pros:

  1. A clean and lightweight API leading to short learning curve and long-term maintainability
  2. Does not need special class constructors, nor imperative base classes

Cons:

  1. Forcing the programmer to write manual table-creation DDL statements instead of automatically deriving it from the model class
  2. Contributors of Storm have to give their contributions' copyrights to Canonical Ltd.

Django's ORM

Pros:

  1. Easy-to-use with a short learning curve
  2. Tightly integrated with Django to make it the de-factor standard when dealing with databases in Django

Cons:

  1. Does not handle complex queries very well; forcing the developer to go back to raw SQL
  2. Tightly integrated with Django; making it hard to use outside of a Django context

peewee

Pros:

  1. A Django-ish API; making it easy-to-use
  2. A lightweight implementation; making it easy to integrate with any web framework

Cons:

  1. Does not support automatic schema migrations
  2. Many-to-Many queries are not intuitive to write

SQLAlchemy

Pros:

  1. Enterprise-level APIs; making the code robust and adaptable
  2. Flexible design; making it painless to write complex queries

Cons:

  1. The Unit-of-work concept is not common
  2. A heavyweight API; leading to a long learning curve

PonyORM

Pros:

  1. A very convenient syntax for writing queries
  2. Automatic query optimization
  3. Simplified setup and usage

Cons:

  1. 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] 比较结论的更多相关文章

  1. Python’s SQLAlchemy vs Other ORMs[转发 6]SQLAlchemy

    SQLAlchemy SQLAlchemy is an open source SQL toolkit and ORM for the Python programming language rele ...

  2. Python’s SQLAlchemy vs Other ORMs[转发 0]

    原文地址:http://pythoncentral.io/sqlalchemy-vs-orms/ Overview of Python ORMs As a wonderful language, Py ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Python’s SQLAlchemy vs Other ORMs[转发 5] PonyORM

    PonyORM PonyORM allows you to query the database using Python generators. These generators are trans ...

  8. 基于Python的SQLAlchemy的操作

    安装 在Python使用SQLAlchemy的首要前提是安装相应的模块,当然作为python的优势,可以到python安装目录下的scripts下,同时按住shift+加上鼠标左键,从而在菜单中打开命 ...

  9. SQLAlchemy(1) -- Python的SQLAlchemy和ORM

    Python的SQLAlchemy和ORM(object-relational mapping:对象关系映射) web编程中有一项常规任务就是创建一个有效的后台数据库.以前,程序员是通过写sql语句, ...

随机推荐

  1. CSS3 Border-image

    CSS3中有关于border的属性我们一起学习完了圆角border-radius和边框颜色border-color,只剩下最后一个边框图片border-image.今天我们就一起来学习这个border ...

  2. ebs history to look for password

    -bash-3.2$ ps -ef|grep tns root 101 2 0 Jun01 ? 00:00:00 [netns] oravibs 10625 1 0 Sep09 ? 00:01:03 ...

  3. canvas中save()和restore()方法

    save()和restore()方法是绘制复杂图形不可缺少的方法它们是分别用来保存和恢复canvas状态的,都没有参数 save():用来保存Canvas的状态.save之后,可以调用Canvas的平 ...

  4. 外国javascript资源搜索

    https://www.javascripting.com/search?q=canvas

  5. HTML5 canvas处理图片的各种效果,包括放大缩小涂鸦等

    http://www.htmleaf.com/ziliaoku/qianduanjiaocheng/201502151385.html jQuery 缩放 旋转 裁剪图片 Image Cropper ...

  6. HHVM和Hack

    1. HHVM(http://hhvm.com)  全称是Hip Hop Virtual Machine,是一个PHP引擎. 2.Hack(http://hacklang.org) 一门新的服务器端语 ...

  7. 渗透测试工具Nmap从初级到高级使用教程

    本文由阿德马翻译自国外网站,请尊重劳动成果,转载请注明出处,谢谢 Nmap是一款网络扫描和主机检测的非常有用的工具.Nmap是不局限于仅仅收集信息和枚举,同时可以用来作为一个漏洞探测器或安全扫描器.它 ...

  8. Jboss配置之数据源密码配置密文--EncryptingDataSourcePasswords

    local-tx-datasource:最常用的数据源配置,该连接池的连接管理器是LocalTxConnectionManager,只支持本地事务,不适合做分布式事务.以mssql为例如下:如果密码按 ...

  9. sublime使用小技巧——自动保存后缀名与自动匹配语法

    1,打开sublime 2,新建文件 3,ctrl+shift+p 4,输入ss(set syntax),在下拉列表中选择需要的语言 列表很多,可以输入相关快捷键 如:html-->ssh cs ...

  10. Ubuntu 14.04下搜狗输入法崩溃重启

    pidof fcitx | xargs kill pidof sogou-qimpanel | xargs kill nohup fcitx >/dev/>/dev/null & ...