Python 3.x 简单表创建中的Python sqlite3操作错误 这是密码 问题
self._db.execute(“创建表,如果不存在票证(ID整数主键自动递增、名称文本、性别文本、订单文本)”)Python 3.x 简单表创建中的Python sqlite3操作错误 这是密码 问题,python-3.x,sqlite,Python 3.x,Sqlite,self._db.execute(“创建表,如果不存在票证(ID整数主键自动递增、名称文本、性别文本、订单文本)”) sqlite3.OperationalError:靠近“Order”:语法错误Order是SQL中的保留字。我建议您找到一个不同的名称,它不是列的保留字(例如,order\u text)。如果您必须使用此名称,可以用双引号(“)将其转义: order是SQL中的保留字。我建议您找到一个不同的名称,它不是列的保留字(例如,order\u text)。如果您绝对必须使用此名称,可以用
sqlite3.OperationalError:靠近“Order”:语法错误
Order
是SQL中的保留字。我建议您找到一个不同的名称,它不是列的保留字(例如,order\u text
)。如果您必须使用此名称,可以用双引号(“
)将其转义:
order
是SQL中的保留字。我建议您找到一个不同的名称,它不是列的保留字(例如,order\u text
)。如果您绝对必须使用此名称,可以用双引号(“
)将其转义:
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()
self._db.execute("create table if not exists Ticket(ID integer primary key autoincrement, Name text, Gender text, \"Order\" text)
# Here -----------------------------------------------------------------------------------------------------------^------^