Reputation: 21
I am using sqlite3 in python3.
Is there anything wrong in my CREATE
statement shown below?
c.execute("CREATE TABLE IF NOT EXISTS transaction(no INTEGER PRIMARY KEY AUTOINCREMENT, ic NONE, borrow INTEGER, timeIn NONE, timeOut NONE")
Error message: sqlite3.OperationalError: near "transaction" : syntax error
Upvotes: 1
Views: 110
Reputation: 26768
As Ignacio
said, transaction
should be quoted and there is a missing right parenthesis.
The query should looks like:
c.execute("CREATE TABLE IF NOT EXISTS 'transaction'(no INTEGER PRIMARY KEY AUTOINCREMENT,
ic NONE, borrow INTEGER,
timeIn NONE,
timeOut NONE)")
Upvotes: 1
Reputation: 799520
"transaction" is a reserved word in SQL. You need to quote it if you want to use it.
... `transaction` (...
Upvotes: 1