是否有任何python Web应用程序框架为SQL和NoSQL提供数据库抽象层?

时间:2020-12-23 08:48:22

Is it even possible to create an abstraction layer that can accommodate relational and non-relational databases? The purpose of this layer is to minimize repetition and allows a web application to use any kind of database by just changing/modifying the code in one place (ie, the abstraction layer). The part that sits on top of the abstraction layer must not need to worry whether the underlying database is relational (SQL) or non-relational (NoSQL) or whatever new kind of database that may come out later in the future.

甚至可以创建一个可以容纳关系数据库和非关系数据库的抽象层吗?此层的目的是最小化重复,并允许Web应用程序通过在一个位置(即抽象层)更改/修改代码来使用任何类型的数据库。位于抽象层顶部的部分不必担心底层数据库是关系数据库(SQL)还是非关系数据库(NoSQL),或者未来可能出现的任何新类型的数据库。

5 个解决方案

#1


2  

There's a Summer of Code project going on right now to add non-relational support to Django's ORM. It seems to be going well and chances are good that it will be merged into core in time for Django 1.3.

现在有一个Summer of Code项目正在为Django的ORM添加非关系支持。它似乎进展顺利,很有可能它会在Django 1.3中及时合并到核心。

#2


2  

You could use stock Django and Django-nonrel ( http://www.allbuttonspressed.com/projects/django-nonrel ) together to get a quite unified experience. Some limits apply, read docs carefully though, remembering Spolsky's "All abstractions are leaky".

你可以使用股票Django和Django-nonrel(http://www.allbuttonspressed.com/projects/django-nonrel)来获得相当统一的体验。一些限制适用,但仔细阅读文档,记住Spolsky的“所有抽象都是漏洞”。

#3


1  

Yo may also check web2py, they support relational databases and GAE on the core.

Yo也可以查看web2py,它们支持核心的关系数据库和GAE。

#4


1  

Regarding App Engine, all existing attempts limit you in some way (web2py doesn't support transactions or namespaces and probably many other stuff, for example). If you plan to work with GAE, use what GAE provides and forget looking for a SQL-NoSQL holy grail. Existing solutions are inevitably limited and affect performance negatively.

关于App Engine,所有现有尝试都会以某种方式限制您(例如,web2py不支持事务或名称空间以及许多其他内容)。如果您打算使用GAE,请使用GAE提供的内容,忘记寻找SQL-NoSQL圣杯。现有的解决方案不可避免地受到限制并且对性能产生负面影

#5


0  

Thank you for all the answers. To summarize the answers, currently only web2py and Django supports this kind of abstraction.

谢谢你的所有答案。总结一下答案,目前只有web2py和Django支持这种抽象。

It is not about a SQL-NoSQL holy grail, using abstraction can make the apps more flexible. Lets assume that you started a project using NoSQL, and then later on you need to switch over to SQL. It is desirable that you only make changes to the codes in a few spots instead of all over the place. For some cases, it does not really matter whether you store the data in a relational or non-relational db. For example, storing user profiles, text content for dynamic page, or blog entries. I know there must be a trade off by using the abstraction, but my question is more about the existing solution or technical insight, instead of the consequences.

它不是关于SQL-NoSQL的圣杯,使用抽象可以使应用程序更加灵活。让我们假设您使用NoSQL启动了一个项目,然后您需要切换到SQL。您最好只在几个地方而不是在整个地方更改代码。在某些情况下,将数据存储在关系数据库或非关系数据库中并不重要。例如,存储用户配置文件,动态页面的文本内容或博客条目。我知道必须通过使用抽象进行权衡,但我的问题更多的是关于现有解决方案或技术洞察力,而不是后果。

#1


2  

There's a Summer of Code project going on right now to add non-relational support to Django's ORM. It seems to be going well and chances are good that it will be merged into core in time for Django 1.3.

现在有一个Summer of Code项目正在为Django的ORM添加非关系支持。它似乎进展顺利,很有可能它会在Django 1.3中及时合并到核心。

#2


2  

You could use stock Django and Django-nonrel ( http://www.allbuttonspressed.com/projects/django-nonrel ) together to get a quite unified experience. Some limits apply, read docs carefully though, remembering Spolsky's "All abstractions are leaky".

你可以使用股票Django和Django-nonrel(http://www.allbuttonspressed.com/projects/django-nonrel)来获得相当统一的体验。一些限制适用,但仔细阅读文档,记住Spolsky的“所有抽象都是漏洞”。

#3


1  

Yo may also check web2py, they support relational databases and GAE on the core.

Yo也可以查看web2py,它们支持核心的关系数据库和GAE。

#4


1  

Regarding App Engine, all existing attempts limit you in some way (web2py doesn't support transactions or namespaces and probably many other stuff, for example). If you plan to work with GAE, use what GAE provides and forget looking for a SQL-NoSQL holy grail. Existing solutions are inevitably limited and affect performance negatively.

关于App Engine,所有现有尝试都会以某种方式限制您(例如,web2py不支持事务或名称空间以及许多其他内容)。如果您打算使用GAE,请使用GAE提供的内容,忘记寻找SQL-NoSQL圣杯。现有的解决方案不可避免地受到限制并且对性能产生负面影

#5


0  

Thank you for all the answers. To summarize the answers, currently only web2py and Django supports this kind of abstraction.

谢谢你的所有答案。总结一下答案,目前只有web2py和Django支持这种抽象。

It is not about a SQL-NoSQL holy grail, using abstraction can make the apps more flexible. Lets assume that you started a project using NoSQL, and then later on you need to switch over to SQL. It is desirable that you only make changes to the codes in a few spots instead of all over the place. For some cases, it does not really matter whether you store the data in a relational or non-relational db. For example, storing user profiles, text content for dynamic page, or blog entries. I know there must be a trade off by using the abstraction, but my question is more about the existing solution or technical insight, instead of the consequences.

它不是关于SQL-NoSQL的圣杯,使用抽象可以使应用程序更加灵活。让我们假设您使用NoSQL启动了一个项目,然后您需要切换到SQL。您最好只在几个地方而不是在整个地方更改代码。在某些情况下,将数据存储在关系数据库或非关系数据库中并不重要。例如,存储用户配置文件,动态页面的文本内容或博客条目。我知道必须通过使用抽象进行权衡,但我的问题更多的是关于现有解决方案或技术洞察力,而不是后果。