Tracing a Syntax Error

Could somebody please help me. When I try to run a new program IDLE gives me the following message

sqlite3.OperationalError: near “Where”: syntax error’‘’ in line 30

I checked several articles on tracing syntax errors and learned that the error would probably be in line 30 or above. The program does create a new database on line 28 and similar code works in other programs, so I am totally confused.

///‘’’

import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
import sqlite3

=====================================

ROOT

=====================================

create instance

root = tk.Tk()

Style as ttk

style = ttk.Style()
style

root.title(“Business Database”)
root.geometry(“1450x700”)

=====================================

DATABASE

=====================================

conn = sqlite3.connect(“appointments.db”)
cursor = conn.cursor()

cursor.execute(“”"
CREATE TABLE IF NOT EXISTS appointments (. # this line works
id INTEGER PRIMARY KEY AUTOINCREMENT,
Date TEXT,
Time Text,
With TEXT,
Where TEXT, # this is line 30
Reason TEXT,
Phone TEXT,
Note TEXT
)
“”")

conn.commit()

///'''

This is a SQL syntax error, not a Python syntax error. You can’t use where as a column name, because it’s a reserved keyword in SQL.

Thank you Clint. I changed “Where” to “location” and it works fine. You have saved me a lot of grief and frustration.

Sean

When posting code or other preformatted text, use triple backticks or select text and use the </> (“Preformatted text (Ctrl E)”) button at the top of the Reply box.