1
votes

here is the code

def __init__(self):
    self._db = sqlite3.connect("Reservation.db")
    self._db.row_factory = sqlite3.Row
    self._db.execute("create table if not exists Ticket(ID integer primary key autoincrement, Name text, Gender text, Order text)")#create a table called Ticket with 4 columns
    self._db.commit()

the proplem

self._db.execute("create table if not exists Ticket(ID integer primary key autoincrement, Name text, Gender text, Order text)") sqlite3.OperationalError: near "Order": syntax error

1

1 Answers

0
votes

order is a reserved word in SQL. I suggest you find a different name, that isn't a reserved word (e.g., order_text) for the column. If you absolutely must use this name, you can escape it by surrounding it with double quotes ("):

self._db.execute("create table if not exists Ticket(ID integer primary key autoincrement, Name text, Gender text, \"Order\" text)
# Here -----------------------------------------------------------------------------------------------------------^------^