该
django.db.connections是包裹一个简单的
DATAbaseS在你的设置中定义。包装器类在这里: django.db.utils#L137-L227
from django.db import connections# Add connection information dynamically..connections.databases['new-alias'] = { ... }# Ensure the remaining default connection information is defined.# EDIT: this is actually performed for you in the wrapper class __getitem__# method.. although it may be good to do it when being initially setup to# prevent runtime errors later.# connections.databases.ensure_defaults('new-alias')# Use the new connectionconn = connections['new-alias']


