首页 \ 问答 \ Django数据库可扩展性(Django database scalability)

Django数据库可扩展性(Django database scalability)

我们有一个新的django供电项目,它具有潜在的重交通特性(意味着重型数据库交互)。 所以我们需要提前考虑数据库的可扩展性。 通过一些研究,我们仍然不清楚以下问题:

  1. 粗粒度:如何为特定的数据库(可能在另一台服务器中)指定一个数据库表(一个django模型)?
  2. 细粒度:如何指定一组表行到特定的数据库(所谓的分片,也可以在另一个数据库服务器中)?
  3. 如何指定写入和读取不同的db?(这将有助于将来的mysql主/从复制)

我们正在寻找解决方案:

  1. 对应用程序透明(意味着我们不需要在views.py中有其他代码)
  2. 应该是ORM级别(意味着只需要在models.py中指定)
  3. 兼容当前(或未来)的django版本(为将来升级django保持最小变化)

我还在做研究。 如果我有一些成果,将在以后分享这个帖子。

希望有经验的人都能回答。 谢谢。


We have a new django powered project which have a potential heavy-traffic characteristic(means a heavy db interaction). So we need to consider the database scalability in advance. With some researches, the following questions are still not clear to us:

  1. coarse-grained: how to specify one db table(a django model) to a specific db(maybe in another server)?
  2. fine-grained: how to specify a group of table rows to a specific db(so-called sharding, also can in another db server)?
  3. how to specify write and read to different db?(which will be helpful for future mysql master/slave replication)

We are finding the solution with:

  1. be transparent to application program(means we don't need to have additional codes in views.py)
  2. should be in ORM level(means only needs to specify in models.py)
  3. compatible with the current(or future) django release(to keep a minimal change for future's upgrading of django)

I'm still doing the research. And will share in this thread later if I've got some fruits.

Hope anyone with the experience can answer. Thanks.


原文:https://stackoverflow.com/questions/1587344
更新时间:2022-07-31 07:07

最满意答案

使用:

ALTER TABLE ADD NewColumn nvarchar(50) NULL

并使用SqlCeCmd.ExecuteNonQuery运行所需的语句


Use:

ALTER TABLE ADD NewColumn nvarchar(50) NULL

and run the required statements using SqlCeCmd.ExecuteNonQuery

相关问答

更多
  • 如果您使用的是Visual Studio,答案是SQL Server数据工具(SSDT)。 它带有SQL Schema Compare功能。 请在此处查看: http : //msdn.microsoft.com/en-us/data/tools.aspx SSDT还可以执行许多其他操作,例如自动数据库测试,自动构建和数据库部署等。 还有第三方替代方案,例如Red Gate的SQL Compare: http : //www.red-gate.com/products/sql-development/sql ...
  • 在我看来,通过检查CSV可以避免很多排他性,以查看实际上会导致数据库更改的记录。 似乎CSV生成器是数据的实际来源,数据库只是它的一面镜子,对吧? 如果是这样,可以忽略导致没有变化的CSV记录,d / b表格不会被截断,剩余的CSV记录可以使用方案2运行,这大概只需要几分钟。 这种方法的主要弱点是如果记录在源头被删除,并且没有迹象表明d / b需要在本地删除它们。 It seems to me that a lot of exclusivity could be avoided by examining t ...
  • 三年来,我学到了很多困难的东西 首先,如果您正在对实时数据进行更新或删除,请首先使用您将要使用的WHERE子句编写一个SELECT查询。 确保它工作。 确保它是正确的。 然后将UPDATE / DELETE语句添加到已知工作的WHERE子句。 你永远不想拥有 DELETE FROM Customers 坐在您的查询分析器中等待您编写WHERE子句...意外地点击“执行”,并且您刚刚杀死了您的客户表。 哎呀。 另外,根据您的平台,了解如何对表进行快速的备份。 在SQL Server 2005中, SELEC ...
  • 如果您的数据库结构正在发生变化,那么您不希望它是自动的。 你将吹走开发工作和数据。 你想要它手动。 我曾经管理过一个类似情况的团队:多TiB数据库,每天更新,需要针对最新数据进行测试和开发。 这是我们解决它的方式: 在我们的数据库中,我们定义了一个名为TODAY()的函数。 在我们的实时系统中,这是NOW()的包装器。 在我们的测试系统中,它调用了一个单列表,其中唯一的行是我们可以设置的日期。 这意味着我们的测试系统是一台时间机器,可以假装任何日期是当前日期。 这意味着我们编写的每个函数或过程都必须具有时间 ...
  • 首先,您需要检测数据库是否为旧数据库。 一种方法是使metadata表具有名称/值文本列( value是保留字,因此使用不同的列名称)并保留当前的schemaVersion。 如果这不存在,那么您知道它是旧版本,但从现在开始,您需要在这些更新期间保持schenaVersion最新。 您可以在该表中保留有关数据库本身的其他信息。 如果数据库根本不同,那么您需要使用您建议的第二种方法: 检测是否有旧版本的数据库,如果没有中止更新。 使用临时文件名创建新数据库。 这包括设置新架构。 一次打开两个数据库。 遍历旧数 ...
  • 实体数据模型有助于从数据库请求数据,它不存储数据。 您的请求将针对服务器数据完成,因此您将从数据库获取最新数据。 但是,如果数据库的结构发生更改,则必须相应地重新创建模型类。 The entity data model helps requesting data from the DB, it doesn't store data. Your request will be done against the server data, so you will get up to date data from ...
  • 您似乎已经复制了前端/后端设置的前端。 后端是数据保存的位置,表格链接到前端以保存表单等。复制前端会复制后端链接,因此数据是实时的。 It seems that you may have copied the front-end of a front-end / back-end set up. The back-end is where data is held and tables are linked to a front-end to hold forms etc. Copying a front- ...
  • 使用: ALTER TABLE ADD NewColumn nvarchar(50) NULL 并使用SqlCeCmd.ExecuteNonQuery运行所需的语句 Use: ALTER TABLE ADD NewColumn nvarchar(50) NULL and run the required statements using SqlCeCmd.ExecuteNonQuery
  • 这两项行动有所不同。 第一个说: 用户应该有两点; 不多也不少。 第二个说: 除了他/她已经拥有的东西之外,用户还应该多得两分。 我不会将这种数据逻辑放在业务逻辑层中。 业务逻辑应该是“用户获得两点”,并且它应该告诉数据库。 它不应该把事情掌握在自己手中,并说“数据库告诉我用户有两点,所以现在他们有四个!” 如果业务层和数据库之间存在延迟,或者在多个线程中同时进行非常多的更新,则这是非常危险的。 我意识到我实际上并没有以明文形式选择我更喜欢的选择: 在业务逻辑中确定用户应获得多少点。 然后发出一个声明,告诉 ...
  • 如果设备硬件能够在没有性能问题的情况下运行MySQL服务器,那么我将在设备和服务器上使用MySQL。 这将节省不同数据格式之间的转换。 您也可以从MySQL的复制功能中受益。 If the device hardware is able to run a MySQL server without performance issues then I would use MySQL on both the device and the server. This would save from translati ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。