开发者

Syntax error in sqlite statement in python?

I have the following code fragment in an object initializer. However, the third line below gives the error sqlite3.OperationalError: near "(": syntax error

self._conn = sqlite3.connect('dictionary')
cursor = self._conn.cursor()
cursor.execute('CREATE TABLE `words` (`word` VARCHAR(15) NOT NULL, PRIMARY (`word`));')

Any ideas as to what could be causing this. I'm far from an export at SQL but I fail to see what I did in开发者_C百科correctly.


You are missing a KEY here.

CREATE TABLE `words` (`word` VARCHAR(15) NOT NULL, PRIMARY KEY(`word`))


PRIMARY word is not valid SQL. Use

CREATE TABLE words (word VARCHAR(15) NOT NULL PRIMARY KEY);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜