在我的 django 应用程序中,我通过从环境变量中获取参数来创建数据库,但它会引发以下错误。
createdb = plumbum.local["createdb"]
File "C:\Users\xyz\lib\site-packages\plumbum\machines\local.py", line 249, in __getitem__
return LocalCommand(self.which(cmd))
File "C:\Users\C:\Users\xyz\lib\site-packages\plumbum\machines\local.py", line 211, in which
raise CommandNotFound(progname, list(cls.env.path))
plumbum.commands.processes.CommandNotFound: ('createdb')
我创建 postgres 数据库的代码:
import plumbum
def create_db():
from myapp import settings
createdb = plumbum.local["createdb"]
for db_name, db_info in settings.DATABASES.items():
createdb["-h", db_info.get("HOST"), "-p", db_info.get("PORT"), db_info.get("NAME")].run(
retcode=[0, 1]
)
如何让它在windows上工作?