本文整理汇总了Python中django.db.utils.ConnectionRouter方法的典型用法代码示例。如果您正苦于以下问题:Python utils.ConnectionRouter方法的具体用法?Python utils.ConnectionRouter怎么用?Python utils.ConnectionRouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.utils
的用法示例。
在下文中一共展示了utils.ConnectionRouter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_routers_cache
# 需要导入模块: from django.db import utils [as 别名]
# 或者: from django.db.utils import ConnectionRouter [as 别名]
def clear_routers_cache(**kwargs):
if kwargs['setting'] == 'DATABASE_ROUTERS':
router.routers = ConnectionRouter().routers
示例2: test_router_init_default
# 需要导入模块: from django.db import utils [as 别名]
# 或者: from django.db.utils import ConnectionRouter [as 别名]
def test_router_init_default(self):
connection_router = ConnectionRouter()
self.assertListEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
示例3: test_router_init_arg
# 需要导入模块: from django.db import utils [as 别名]
# 或者: from django.db.utils import ConnectionRouter [as 别名]
def test_router_init_arg(self):
connection_router = ConnectionRouter([
'multiple_database.tests.TestRouter',
'multiple_database.tests.WriteRouter'
])
self.assertListEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
# Init with instances instead of strings
connection_router = ConnectionRouter([TestRouter(), WriteRouter()])
self.assertListEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
# Make the 'other' database appear to be a replica of the 'default'
示例4: test_router_init_default
# 需要导入模块: from django.db import utils [as 别名]
# 或者: from django.db.utils import ConnectionRouter [as 别名]
def test_router_init_default(self):
connection_router = ConnectionRouter()
self.assertEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
示例5: test_router_init_arg
# 需要导入模块: from django.db import utils [as 别名]
# 或者: from django.db.utils import ConnectionRouter [as 别名]
def test_router_init_arg(self):
connection_router = ConnectionRouter([
'multiple_database.tests.TestRouter',
'multiple_database.tests.WriteRouter'
])
self.assertEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
# Init with instances instead of strings
connection_router = ConnectionRouter([TestRouter(), WriteRouter()])
self.assertEqual([r.__class__.__name__ for r in connection_router.routers], ['TestRouter', 'WriteRouter'])
# Make the 'other' database appear to be a replica of the 'default'