V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ifoolish
V2EX  ›  Python

Django ORM 实现能否实现在第一次打开页面时才配置数据库?

  •  
  •   ifoolish · 2017-05-03 20:27:36 +08:00 · 1927 次点击
    这是一个创建于 2543 天前的主题,其中的信息可能已经有所发展或是发生改变。

    例如两个主机上的 MySQL 配置了主主同步,数据表均已建好,但事先并不知道用户要用哪个库,第一次打开页面时要让用户填写数据库的 IP 并保存使用。Django 在使用 ORM 的情况下要如何实现?

    2 条回复    2017-05-04 11:06:39 +08:00
    Victor215
        1
    Victor215  
       2017-05-03 20:31:03 +08:00 via Android
    用另外一个服务来配置这个服务
    ryanking8215
        2
    ryanking8215  
       2017-05-04 11:06:39 +08:00
    @ifoolish django orm 可以设置多个 DB,也可以动态增加 DB,通过 DBRouter 来控制访问。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2743 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 14:51 · PVG 22:51 · LAX 07:51 · JFK 10:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.