1

The following code shows up this error when run.

Error:

 INTEGER PRIMARY KEY LadID)""".format(usr))
 sqlite3.OperationalError: near "LadID": syntax error

Code:

c.execute("""CREATE TABLE {}
        (LadID INTEGER,
        foreName TEXT,
        surname TEXT,
        interests INTEGER,
        gender TEXT,
        mob INTEGER
        INTEGER PRIMARY KEY (LadID))""".format(usr))

What is the solution?

1 Answer 1

1

Seems that you have omitted a comma after mob INTEGER also you need to change the last column to LadID INTEGER PRIMARY KEY.

Note that you should put your column name at the start of column definition and don't need to parenthesis.

c.execute("""CREATE TABLE {}
        (LadID INTEGER,
        foreName TEXT,
        surname TEXT,
        interests INTEGER,
        gender TEXT,
        mob INTEGER,
        LadID INTEGER PRIMARY KEY)""".format(usr))
Sign up to request clarification or add additional context in comments.

5 Comments

But now I get this: sqlite3.OperationalError: near "(": syntax error
Why you have putted LadID within parenthesis? in INTEGER PRIMARY KEY (LadID)
Without the parenthesis I get sqlite3.OperationalError: near "LadID": syntax error
It can be LadID INTEGER PRIMARY KEY anyway.
@TomHaines marcus is right you need to put the column name on first LadID INTEGER PRIMARY KEY

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.