开发者

Syntax error in sqlite statement in python?

开发者 https://www.devze.com 2023-03-28 17:52 出处:网络
I have the following code fragment in an object initializer. However, the third line below gives the error sqlite3.OperationalError: near \"(\": syntax error

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

精彩评论

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