繁体   English   中英

Python Django未知命令'SQL'

[英]Python Django Unknown Command 'SQL'

我正在关注本教程http://www.sitepoint.com/building-simple-rest-api-mobile-applications/

我正在尝试运行SQL

$ python manage.py sql fishes

然而它说

Unknown Command: 'sql'

如果我输入

$ python manage.py help

我明白了,SQL没有出现在列表中。

Available subcommands:

[auth]
    changepassword
    createsuperuser

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[sessions]
    clearsessions

[staticfiles]
    collectstatic
    findstatic
    runserver

不幸的是,这不再存在,但是命令manage.py dbshell

但是,一般来说,您应该尝试使用load_data等模型来保持数据的完整性(因为验证等可能在模型中发生,而不是依赖于底层数据位)。 或者为任何清理任务编写管理命令。

是的,可以使用inspectdb命令:

python manage.py inspectdb

要么

python manage.py inspectdb > models.py

让他们进入文件

这将查看settings.py配置的数据库,并将模型类输出到标准输出。

正如Ignacio指出的那样,文档中提供了有关您的情况指南

来源: 链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM