web2py sql行中的异常

时间:2010-01-05 13:24:50

标签: python web2py

当我执行以下代码时:

family_members =db(db.member.id == membership_id).select
(db.member.name,db.member.id)
family_members.colnames = ('Name','Membership ID')

导致以下错误......

Traceback (most recent call last):
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
restricted.py", line 184, in restricted
  File "/home/abeer/Desktop/resources/web2py/New_version/web2py_src/
web2py/applications/init/views/default/updateMember.html", line 142,
in <module>
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
globals.py", line 112, in write
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
html.py", line 103, in xmlescape
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sql.py", line 3326, in xml
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sqlhtml.py", line 980, in __init__
  File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sql.py", line 621, in __getattr__
  KeyError: '_extra'

P.S。 :当我评论(family_members.colnames = ('Name','Membership ID'))行时,它运行正常,但我不明白为什么。

1 个答案:

答案 0 :(得分:0)

请勿使用colnames。该属性是web2py的内部属性。根据您的需要,使用db.table.field.label='..'SQLTABLE(rows, headers={...})