I am trying Chapter 6 from Django book.
我正在尝试Django书中的第6章。
After changing some fields to blank=True, and null=True, we are told to update the table using dbshell.
将某些字段更改为blank = True,并且null = True后,我们被告知使用dbshell更新表。
When I type: python manage.py dbshell, the following error appears:
当我键入:python manage.py dbshell时,出现以下错误:
C:\Users\Rafa\Documents\Python\book>python manage.py dbshell
Error: near: "Documents": syntax error.
I tried installing sqlite3.exe in my book directory and running directly from there. I still get the same error anytime I try to run a command. For example, once on the sqlite3 shell (opening executable file):
我尝试在我的book目录中安装sqlite3.exe并直接从那里运行。我尝试运行命令时仍然会遇到相同的错误。例如,一旦在sqlite3 shell上(打开可执行文件):
sqlite>ALTER TABLE books_book ALTER COLUMN publication_date DROP NOT NULL;
Error: near "ALTER": syntax error.
I know the commands may be wrong, but I can try anything and it will always point the same error and show the first word of the command in the "".
我知道命令可能是错误的,但我可以尝试任何东西,它总是指出相同的错误,并在“”中显示命令的第一个单词。
Any help?
3 个解决方案
#1
1
SQLite has very limited ALTER TABLE
support.
SQLite具有非常有限的ALTER TABLE支持。
You have to drop and recreate the table.
您必须删除并重新创建表。
#2
0
As the error message suggests, there is a syntax error somewhere. You should check (or post here) the parts which describe Documents
class for some syntactic mistakes :)
正如错误消息所示,某处存在语法错误。您应该检查(或在此处发布)描述Documents类的部分,以解决一些语法错误:)
#3
0
I realize now that Django does not support database migrations very well. Once you do the initial migration and the original table is set, it is impossible to add or modify fields with Django only. You need a database migration schema like South.
我现在意识到Django不能很好地支持数据库迁移。完成初始迁移并设置原始表后,无法仅使用Django添加或修改字段。您需要像South这样的数据库迁移模式。
#1
1
SQLite has very limited ALTER TABLE
support.
SQLite具有非常有限的ALTER TABLE支持。
You have to drop and recreate the table.
您必须删除并重新创建表。
#2
0
As the error message suggests, there is a syntax error somewhere. You should check (or post here) the parts which describe Documents
class for some syntactic mistakes :)
正如错误消息所示,某处存在语法错误。您应该检查(或在此处发布)描述Documents类的部分,以解决一些语法错误:)
#3
0
I realize now that Django does not support database migrations very well. Once you do the initial migration and the original table is set, it is impossible to add or modify fields with Django only. You need a database migration schema like South.
我现在意识到Django不能很好地支持数据库迁移。完成初始迁移并设置原始表后,无法仅使用Django添加或修改字段。您需要像South这样的数据库迁移模式。