有什么好的Python ORM解决方案? [英] What are some good Python ORM solutions?

查看:98
本文介绍了有什么好的Python ORM解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估并考虑将CherryPy用于一个项目,该项目基本上是客户端(浏览器)的JavaScript前端,可与后端的Python Web服务进行通信.因此,我确实需要在后端实现快速,轻便的功能,我可以使用Python实现该功能,然后通过ORM(浏览器的JSON)与PostgreSQL数据库对话.

I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB via an ORM (JSON to the browser).

我还在看我喜欢的Django,因为它的ORM是内置的.但是,我认为Django可能比我真正需要的要多(即比我真正需要的功能更多==慢吗?).

I'm also looking at Django, which I like, since its ORM is built-in. However, I think Django might be a little more than I really need (i.e. more features than I really need == slower?).

任何人都具有使用不同Python ORM解决方案的经验,这些解决方案可以比较和对比其特性和功能,速度,效率等.

Anyone have any experience with different Python ORM solutions that can compare and contrast their features and functionality, speed, efficiency, etc.?

推荐答案

SQLAlchemy功能更强大,功能更强大(使用DataMapper模式). Django ORM的语法更简洁,更易于编写(ActiveRecord模式).我不知道性能差异.

SQLAlchemy is more full-featured and powerful (uses the DataMapper pattern). Django ORM has a cleaner syntax and is easier to write for (ActiveRecord pattern). I don't know about performance differences.

SQLAlchemy还具有一个声明层,它可以隐藏有点复杂,并使其具有类似于Django ORM的ActiveRecord样式语法.

SQLAlchemy also has a declarative layer that hides some complexity and gives it a ActiveRecord-style syntax more similar to the Django ORM.

我不会担心Django太笨重".它已经足够解耦,因此您可以在不需要导入其余部分的情况下使用ORM.

I wouldn't worry about Django being "too heavy." It's decoupled enough that you can use the ORM if you want without having to import the rest.

也就是说,如果我已经在Web层上使用CherryPy并且只需要一个ORM,那么我可能会选择SQLAlchemy.

That said, if I were already using CherryPy for the web layer and just needed an ORM, I'd probably opt for SQLAlchemy.

这篇关于有什么好的Python ORM解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆