1

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

0

1 Answer 1

0

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 -----------------------------------------------------------------------------------------------------------^------^
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.