Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
操作错误:接近“;(“语法错误”位于SQLite3_Sqlite - Fatal编程技术网

操作错误:接近“;(“语法错误”位于SQLite3

操作错误:接近“;(“语法错误”位于SQLite3,sqlite,Sqlite,在参加SQLite3速成课程后,我尝试为我的第一个项目制作db: import sqlite3 as db conn = db.connect('todo.db') cursor = conn.cursor() cursor.execute("CREATE TABLE todo(id serial primary key, title text, created timestamp default now(), done boolean default 'f')") cursor.exe

在参加SQLite3速成课程后,我尝试为我的第一个项目制作db:

import sqlite3 as db

conn = db.connect('todo.db')
cursor = conn.cursor()

cursor.execute("CREATE TABLE todo(id serial primary key, title text, created 
timestamp default now(), done boolean default 'f')")

cursor.execute("INSERT INTO todo (title) VALUES('Learn web.py')")
很遗憾,我收到了以下错误:

操作错误:在SQLite3的“(”:语法错误”附近

我不明白代码出了什么问题。有人能解释一下我做错了什么吗?

如中所示,如果默认值不是简单的值,则必须用括号括起来:

CREATE TABLE todo(
    ...,
    created timestamp default (now()),
    done boolean default 'f'
);
(并且
'f'
不是a的有效值,
now()
不是SQLite函数。)