久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <i id='V0YEa'><tr id='V0YEa'><dt id='V0YEa'><q id='V0YEa'><span id='V0YEa'><b id='V0YEa'><form id='V0YEa'><ins id='V0YEa'></ins><ul id='V0YEa'></ul><sub id='V0YEa'></sub></form><legend id='V0YEa'></legend><bdo id='V0YEa'><pre id='V0YEa'><center id='V0YEa'></center></pre></bdo></b><th id='V0YEa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='V0YEa'><tfoot id='V0YEa'></tfoot><dl id='V0YEa'><fieldset id='V0YEa'></fieldset></dl></div>
      <tfoot id='V0YEa'></tfoot>
      • <bdo id='V0YEa'></bdo><ul id='V0YEa'></ul>

        <small id='V0YEa'></small><noframes id='V0YEa'>

        <legend id='V0YEa'><style id='V0YEa'><dir id='V0YEa'><q id='V0YEa'></q></dir></style></legend>
      1. 混合 PostgreSQL 和 MongoDB(作為 Django 后端)

        Mixing PostgreSQL and MongoDB (as Django backends)(混合 PostgreSQL 和 MongoDB(作為 Django 后端))
      2. <legend id='GufAp'><style id='GufAp'><dir id='GufAp'><q id='GufAp'></q></dir></style></legend>

        <tfoot id='GufAp'></tfoot>

              <bdo id='GufAp'></bdo><ul id='GufAp'></ul>
                <tbody id='GufAp'></tbody>

              <small id='GufAp'></small><noframes id='GufAp'>

                <i id='GufAp'><tr id='GufAp'><dt id='GufAp'><q id='GufAp'><span id='GufAp'><b id='GufAp'><form id='GufAp'><ins id='GufAp'></ins><ul id='GufAp'></ul><sub id='GufAp'></sub></form><legend id='GufAp'></legend><bdo id='GufAp'><pre id='GufAp'><center id='GufAp'></center></pre></bdo></b><th id='GufAp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GufAp'><tfoot id='GufAp'></tfoot><dl id='GufAp'><fieldset id='GufAp'></fieldset></dl></div>
                1. 本文介紹了混合 PostgreSQL 和 MongoDB(作為 Django 后端)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  出于性能原因,我正在考慮將我的網站后端從 Postgres 轉移到 Mongo,但該網站的關鍵部分依賴 GeoDjango 模型來計算現實世界中對象之間的距離(等等).

                  I'm thinking about shifting my site's backend to Mongo from Postgres for performance reasons, but key parts of the site rely on the GeoDjango models to calculate distances between objects in the real world (and so on).

                  讓大部分站點在 Mongo 上運行但那些關鍵區域使用 Postgres 進行存儲是否可行?這是痛苦的和/或容易出錯的嗎?是否有我缺少的全 Mongo 解決方案?

                  Would it be feasible to have most of the site running on Mongo but those key areas using Postgres for storage? Is this painful and / or error-prone? Is there an all-Mongo solution I'm missing?

                  如果您能為我提供關于這些問題的任何啟示,我們將不勝感激.

                  Any light you can shed on these matters for me would be much appreciated.

                  推薦答案

                  從Django 1.2開始,你可以在您的 settings.py 中定義多個數據庫連接.然后你可以使用數據庫路由器 告訴 Django 去哪個數據庫,對你的應用程序透明.

                  Since Django 1.2, you can define multiple datbase connections in your settings.py. Then you can use database routers to tell Django which database to go to, transparently for your application.

                  免責聲明:這就是我認為應該如何工作的方式,我從未在 Django 中使用過 MongoDB,也沒有測試過我的代碼是否真的有效.:)

                  Disclaimer: this is how I think it should work, I have never used MongoDB in Django, nor have I tested that my code actually works. :)

                  DATABASES = {
                      'default': {
                          'ENGINE': 'django_mongodb_engine',
                          'NAME': 'mydata',
                          ...
                      }
                      'geodata' {
                          'ENGINE': 'django.db.backends.postgresql_psycopg2',
                          'NAME': 'geodata',
                          ...
                      }
                  }
                  
                  DATABASE_ROUTERS = ['path.to.ModelMetaRouter']
                  

                  型號

                  然后將自定義元變量添加到您的地理表中,以覆蓋其數據庫.不要將此屬性添加到應該轉到默認數據庫的模型中.

                  Models

                  Then add custom Meta variables to your geo-tables, to override their database. Don't add this attribute to models that are supposed to go to the default database.

                  class SomeGeoModel(models.Model):
                      ...
                      class Meta:
                          using = 'geodata'
                  

                  數據庫路由器

                  并編寫一個數據庫路由器來將所有具有 using 元屬性集的模型定向到適當的連接:

                  Database router

                  And write a database router to direct all models that have the using meta attribute set, to the appropriate connection:

                  class ModelMetaRouter(object):
                      def db_for_read(self, model, **hints):
                          return getattr(model._meta, 'using', None)
                  
                      def db_for_write(self, model, **hints):
                          return getattr(model._meta, 'using', None)
                  
                      def allow_relation(self, obj1, obj2, **hints):
                          # only allow relations within a single database
                          if getattr(obj1._meta, 'using', None) == getattr(obj2._meta, 'using', None):
                              return True
                          return None
                  
                      def allow_syncdb(self, db, model):
                          if db == getattr(model._meta, 'using', 'default'):
                              return True
                          return None
                  

                  這篇關于混合 PostgreSQL 和 MongoDB(作為 Django 后端)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                2. <tfoot id='3ymUz'></tfoot>
                3. <small id='3ymUz'></small><noframes id='3ymUz'>

                4. <legend id='3ymUz'><style id='3ymUz'><dir id='3ymUz'><q id='3ymUz'></q></dir></style></legend>
                  <i id='3ymUz'><tr id='3ymUz'><dt id='3ymUz'><q id='3ymUz'><span id='3ymUz'><b id='3ymUz'><form id='3ymUz'><ins id='3ymUz'></ins><ul id='3ymUz'></ul><sub id='3ymUz'></sub></form><legend id='3ymUz'></legend><bdo id='3ymUz'><pre id='3ymUz'><center id='3ymUz'></center></pre></bdo></b><th id='3ymUz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3ymUz'><tfoot id='3ymUz'></tfoot><dl id='3ymUz'><fieldset id='3ymUz'></fieldset></dl></div>

                    <tbody id='3ymUz'></tbody>

                          <bdo id='3ymUz'></bdo><ul id='3ymUz'></ul>

                            主站蜘蛛池模板: 欧美视频精品 | 日本免费一区二区三区视频 | 亚洲国产一 | 国产三级精品三级在线观看四季网 | 精精国产xxxx视频在线播放 | 一区二区三区国产精品 | 国产成人精品999在线观看 | 欧美黄色片 | 欧美性另类 | 观看av| 久热久热 | 97色在线观看免费视频 | 中文字幕精品一区二区三区精品 | 天堂资源| 日韩欧美亚洲一区 | 亚洲一区精品在线 | 欧美成人手机在线 | 国偷自产av一区二区三区 | 不卡一区二区三区四区 | 久久只有精品 | 亚洲精品国产精品国自产在线 | 国产福利一区二区 | h视频免费观看 | 91在线第一页 | 99re热这里只有精品视频 | 91精品国产日韩91久久久久久 | 美女久久久久久久 | 91 视频网站 | 欧美激情亚洲激情 | 久久a久久 | 最新中文字幕一区 | 久久综合狠狠综合久久综合88 | 美女在线视频一区二区三区 | 一区在线观看 | 久久综合一区二区三区 | 欧美一区二区三区四区五区无卡码 | 日韩精品一区二区三区中文在线 | 色网站在线 | 国产高清一区二区 | 狠狠av| 国产精品呻吟久久av凹凸 |