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 incorrectly.
asked Aug 18, 2011 at 6:45
Tyler Crompton
12.8k15 gold badges69 silver badges99 bronze badges
2 Answers 2
You are missing a KEY here.
CREATE TABLE `words` (`word` VARCHAR(15) NOT NULL, PRIMARY KEY(`word`))
answered Aug 18, 2011 at 6:48
Jacob
43.6k6 gold badges81 silver badges81 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
PRIMARY word is not valid SQL. Use
CREATE TABLE words (word VARCHAR(15) NOT NULL PRIMARY KEY);
answered Aug 18, 2011 at 6:49
hamstergene
24.5k5 gold badges61 silver badges73 bronze badges
Comments
default