1

So far this is the code I have and I keep getting an error stating: "sqlite3.OperationalError: near ")": syntax error"

import sqlite3
con = sqlite3.connect("DatabaseName.sql")

cur = con.cursor()

cur.execute("""CREATE TABLE Contacts (Fname TEXT,
Lname TEXT, Phone INTEGER,)""")

Fname = input("Enter first name: ")
Lname = input("Enter last name: ")
Phone = input("Enter telephone number(no dashes or spaces): ")
Phone = int(Phone)


cur.execute("""INSERT INTO Contacts (Fname, Lname, Phone, joined_club)
VALUES (?,?,?)""", (Fname,Lname,Phone))

con.commit()

cur.close()
con.close()

1 Answer 1

4

You have an extra comma in your create statement, before the close paren. It should be:

cur.execute("""CREATE TABLE Contacts (Fname TEXT,
Lname TEXT, Phone INTEGER)""")

Later on, you have an extra parameter, joined_club, in your INSERT statement. It should be:

cur.execute("""INSERT INTO Contacts (Fname, Lname, Phone)
VALUES (?,?,?)""", (Fname,Lname,Phone))
Sign up to request clarification or add additional context in comments.

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.