2

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.

2 Answers 2

4

You are missing a KEY here.

CREATE TABLE `words` (`word` VARCHAR(15) NOT NULL, PRIMARY KEY(`word`))
Sign up to request clarification or add additional context in comments.

Comments

0

PRIMARY word is not valid SQL. Use

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.