Django/Python应用程序的数据库引擎选择 您所在的位置:网站首页 python的数据库应用 Django/Python应用程序的数据库引擎选择

Django/Python应用程序的数据库引擎选择

2023-03-15 07:01| 来源: 网络整理| 查看: 265

1  

I think it depends on your requirements and that is a question only you can answer. I think the notion that it is easier to setup is silly. You are software professionals, use what works, learn the tools. On ubuntu, setting up a dev postgres is pretty much an app-get away for instance.

我认为这取决于你的要求,这是一个只有你才能回答的问题。我认为更容易设置的想法是愚蠢的。您是软件专业人员,使用什么工作,学习工具。在ubuntu上,设置一个开发postgres是一个很好的应用程序-例如。

The very first question you should ask is SQL a good fit for what we are doing at all? If not, use something else (though you may want to choose something other than Django, and I say this as a Django-non-rel heavy user), if so, continue.

您应该问的第一个问题是SQL是否适合我们正在做的事情?如果没有,请使用其他内容(尽管您可能希望选择Django之外的内容,我以Django-non-rel用户的身份对此进行说明),如果有,请继续。

The good thing is that in Django, if you really don't want to setup Postgres for use in your development environment, you can simply use your settings files to swap database types between environments such as dev and production. That of course assumes that you are not doing anything Postgres specific in Django, i.e. you are simply using the ORM and features/libraries in Django that are not database specific. In your case, this doesn't sound like it would be an issue.

好在Django中,如果您确实不想在开发环境中使用Postgres,那么可以使用设置文件在开发环境(如dev和产品)之间交换数据库类型。当然,这假定您没有在Django中执行任何特定于Postgres的操作,也就是说,您只是在Django中使用ORM和特性/库,这些都不是特定于数据库的。在你的情况下,这听起来不像是一个问题。

Disclaimer: I strongly suggest though you test heavily on Postgres if you are also using SQLite in dev. You never know what integration issues can pop-up and certainly the performance characteristics are dramatically different. If it makes you feel better, Google themselves in the Google App Engine SDK for example uses SQLite to simulate the App Engine datastore at dev time.

免责声明:我强烈建议如果您在开发中也使用SQLite,那么您可以在Postgres上进行大量的测试。如果它让您感觉更好,谷歌自己在谷歌应用程序引擎SDK中,例如使用SQLite在dev时模拟App Engine datastore。

Anyway, first, ready SQLite official use-cases claims. Moreover, see the implementation limits and see if any will cause problems for your requirements.

总之,首先,准备好SQLite的官方用例声明。此外,请查看实现限制,看看是否有任何限制会对您的需求造成问题。

General SQLite Pros:

一般SQLite优点:

Easy to setup, light-weight, more of a single-user or low volume database 易于安装,重量轻,多为单用户或低容量数据库 Can be embedded into other applications easily, for example a game 可以很容易嵌入到其他应用程序中,比如游戏? Portable 可移植的 Fast enough, gets the job done 足够快,完成任务。 Simple cases like a small system or replacing direct disk access 简单的例子,像一个小的系统或更换直接的磁盘存取。

Postgres is a much more robust database that is designed to support a variety of different size applications that benefit from using a relational database. Generally it has almost all the features of SQLite and many more, but is obviously harder to setup, is not really designed to be quickly embedded, and is a bit less portable. In other words, not so lite :)

Postgres是一个健壮得多的数据库,旨在支持各种不同大小的应用程序,这些应用程序可以从使用关系数据库中获益。一般来说,它几乎具有SQLite的所有特性,还有更多的特性,但是显然很难设置,并不是设计为快速嵌入,而且不太容易移植。换句话说,不是那么简单

Have a look at this features matrix for Postgres.

看一下这个特性矩阵。

Here is a more direct comparison in one place.

这里有一个更直接的比较。

General Postgres Pros:

一般Postgres优点:

Designed to be multi-user 设计多用户 Lots of useful tools in the chain including things like backup and replication 链中有很多有用的工具,包括备份和复制 Comprehensive feature set for data types, operations running inside the DB like procedures, etc. 对数据类型、在DB内运行的操作(如过程)等进行全面的特性设置。 Can scale decently if you are competent in SQL and using SQL for the right reasons. 如果您能够胜任SQL,并且出于正确的原因使用SQL,那么可以适当地扩展。 ACID compliance and transactions are stressed and fully implemented 强调ACID遵从性和事务并充分实现

;tldr - Use Postgres if you want to plan for the long-term and feel confident. If you don't care, use SQLite if you must. Enjoy the best of both worlds if you want by using Django to switch databases via settings as long as you don't do anything DB specific.

;tldr -如果你想为长期计划而感到自信,可以使用Postgres。如果你不介意,可以使用SQLite。如果您想使用Django通过设置切换数据库,只要您不做任何特定于DB的事情,就可以享受这两个方面的好处。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有