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

查看:26
本文介绍了有哪些好的 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.

也就是说,如果我已经将 CherryPy 用于 Web 层并且只需要一个 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天全站免登陆