[英]How can i use different database in django management command
I am using django management command in my test like this 我在像这样的测试中使用django管理命令
from django.core.management import call_command
call_command('loadusers')
Now I have the database on external server where i want to execute this command not on the database where the django currently is executing the tests. 现在,我在要执行此命令的外部服务器上有数据库,而不是在django当前正在执行测试的数据库上。
How can i something like 我怎么会这样
call_command('loadusers', database="external")
settings.DATABASES[FIXTURE_DATABASE] = {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "external",
}
call_command("loadusers", database=FIXTURE_DATABASE, verbosity=0,
interactive=False)
I think it should work,found this here at Example 14 : http://www.programcreek.com/python/example/56194/django.core.management.call_command 我认为应该可以,请在示例14中找到它: http : //www.programcreek.com/python/example/56194/django.core.management.call_command
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.