我启动了一个名为 GREEN.db 的新数据库,其中一个 TABLE 定义如下:
CREATE TABLE articles(
"articleID" serial NOT NULL,
"articleTitle" character varying(21) NOT NULL,
"articleContent" text NOT NULL,
"articleAuthor" character varying(7) NOT NULL ,
"articleTime" timestamp without time zone DEFAULT now(),
CONSTRAINT articles_pkey PRIMARY KEY ("articleID")
)
我的代码编写如下:
db = web.database(dbn='postgres', db='green',user='YOng',password='xxx')
......
i = web.input()
t = time.localtime(time.time())
st = time.strftime("%Y-%m-%d %H:%M:%S", t)
datas = list(db.query("""SELECT * FROM articles ORDER BY "articleID" DESC"""))
n = db.insert("articles",
articleID=len(datas)+1, \
articleTitle=i.post_title, \
articleContent=i.post_content, \
articleAuthor="YOng", \
articleTime=st)
web.seeother('/')
错误抛出说:
psycopg2.ProgrammingError:关系“articles”的列“articleid”不存在第1行:插入文章(articleTitle,articleAuthor,articleID ... ^
我不知道这段代码发生了什么。有人有什么建议吗?任何帮助表示赞赏~