我有一个名为foo的数据库(mysql)表,它的主键是bigint类型,并且自动递增, 我编写以下代码来插入记录并获取记录的主键
q = db.insert('foo', name='bob', age=2, _test=True)
print q
该记录已插入表中,但出现以下错误:
type 'exceptions.TypeError' : 'long' object is unsubscriptable
你能帮我做什么吗?
最佳答案
您得到 TypeError: '<type>' object is not subscriptable
当您尝试使用 __getitem__
时出错与不支持它的对象的接口(interface)。通常看起来像这样 container[...]
.
查看完整的回溯。在某个地方,您应该看到一个对象以这种方式被访问。由于您没有显示完整的回溯或代码的其余部分,我无法告诉您在哪里。
关于python - web.py db.insert函数抛出错误: <type 'exceptions.TypeError' > : 'long' object is unsubscriptable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6967210/