<type 'exceptions.KeyError'> 'Column table.id not found (SQLTABLE)'

315 views
Skip to first unread message

LoveWeb2py

unread,
Mar 12, 2017, 7:27:08 PM3/12/17
to web2py-users
Keep getting this error for all of my tables!! What is going on?

What information would be helpful for me to post to get help?

Anthony

unread,
Mar 12, 2017, 8:30:50 PM3/12/17
to web2py-users
On Sunday, March 12, 2017 at 7:27:08 PM UTC-4, LoveWeb2py wrote:
Keep getting this error for all of my tables!! What is going on?

What information would be helpful for me to post to get help?

The usual -- code and traceback.

LoveWeb2py

unread,
Mar 12, 2017, 9:36:18 PM3/12/17
to web...@googlegroups.com

Error ticket for "myapp"

Ticket ID

127.0.0.1.2017-03-12.21-35-27.2a6dfbe0-ddb4-43db-9e3d-e43542a6c1f2

<type 'exceptions.KeyError'> 'Column my_table.id not found (SQLTABLE)'

Version

web2py™Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
PythonPython 2.7.13: /usr/local/opt/python/bin/python2.7 (prefix: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
Traceback (most recent call last):
File "/code/web-dev/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/code/web-dev/web2py/applications/myapp/views/appadmin.html", line 173, in <module>
{{
if object_stats:}}
File "/code/web-dev/web2py/gluon/sqlhtml.py", line 3274, in __init__
"Column %s not found (SQLTABLE)" % colname)
KeyError: 'Column nba_match.id not found (SQLTABLE)'

Error snapshot help

<type 'exceptions.KeyError'>('Column my_table.id not found (SQLTABLE)')

inspect attributes

Frames

  • File /code/web-dev/web2py/gluon/restricted.py in restricted at line 227 code arguments variables

  • File /code/web-dev/web2py/applications/myapp/views/appadmin.html in <module> at line 173 code arguments variables

  • File /code/web-dev/web2py/gluon/sqlhtml.py in __init__ at line 3274 code arguments variables

    Function argument list

    (self=<gluon.sqlhtml.SQLTABLE object>, sqlrows=<Rows (100)>, linkto=<function <lambda>>, upload='/myapp/appadmin/download/db', orderby=True, headers={}, truncate=16, columns=['nba_match.id', 'my_table.field1', 'my_table.field2', 'my_table.field3', 'my_table.field4', 'my_table.field5', 'my_table.field6'], th_link='', extracolumns=None, selectid=None, renderstyle=False, cid=None, colgroup=False, **attributes={'_class': 'sortable'})

    Code listing
    3269.
    3270.
    3271.
    3272.
    3273.
    3274.

    3275.
    3276.
    3277.
    3278.
                            r = record._extra[colname]
    row.append(TD(r))
    continue
    else
    :
    raise KeyError(
    "Column %s not found (SQLTABLE)" )

    (
    tablename, fieldname) = matched_column_field.groups()
    colname = tablename + '.' + fieldname
    try:
    field = sqlrows.db[tablename][fieldname]
    Variables
    colname'my_table.id'

Context

Peter Weicher

unread,
Mar 20, 2017, 9:36:00 AM3/20/17
to web2py-users
@LoveWeb2py

Two questions:

1) Are you running web2py from windows distribution binary or source?
2) can you view ANY other tables besides my_table in that application?

I have seen this error too, and my steps to reproduce are below. Still analyzing the root cause.

Here is how I reproduced this error:

1) bad install of web2py source from git. See Exhibit A. 
2) Create an application and then use signup form to add a user to the auth_user table.
3) try to view any table after that, I get the same KeyError citing that column auth_user.id does not exist in table. 
4) try the same steps from windows compiled distribution of web2py and everything works fine. 

I am guessing that there is some missing or misversioned library that creates a bad insert statement screwing up the db. 

Thanks, 
Peter 


Exhibit A - my install from source had problems.

Here is how I installed web2py from source. Because the git submodule update --init --recursive failed (still researching why), I instead pip'd pydal in and got the server running.

Windows Command Prompt

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>c:\python27\python.exe c:\web2py-master\web2py.py
Traceback (most recent call last):
  File "c:\web2py-master\web2py.py", line 21, in <module>
    import gluon.widget
  File "c:\web2py-master\gluon\__init__.py", line 31, in <module>
    "You can also download a complete copy from http://www.web2py.com."
RuntimeError: web2py depends on pydal, which apparently you have not installed.
Probably you cloned the repository using git without '--recursive'
To fix this, please run (from inside your web2py folder):

     git submodule update --init --recursive

You can also download a complete copy from http://www.web2py.com.

C:\>cd c:\web2py-master

c:\web2py-master>git submodule update --init --recursive
fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?

c:\web2py-master>c:\python27\python.exe -m pip install pydal
Collecting pydal
  Using cached pyDAL-17.3-py2.py3-none-any.whl
Installing collected packages: pydal
Successfully installed pydal-17.3

Santiago Cartasegna

unread,
Mar 20, 2017, 9:39:13 AM3/20/17
to web2py-users
Are you trying to use a table that you have defined in your database and not in web2py? 
If it is the case you must add an id field with autoincremental

Maurice Waka

unread,
Jun 3, 2017, 12:13:18 PM6/3/17
to web2py-users
Hi did anyone get to solve this error? I seem to be locked in it also
Regards

Najtsirk

unread,
Jun 3, 2017, 12:30:05 PM6/3/17
to web2py-users
+1
Have this problem too!

Najtsirk

unread,
Jun 3, 2017, 12:33:17 PM6/3/17
to web2py-users
I checked this and I had pydal installed as a global module. 
When I removed it web2py's DAL works ok.

Brian M

unread,
Apr 20, 2018, 9:05:28 PM4/20/18
to web2py-users
Thank you for mentioning this - just wasted an hour plus trying to figure out why my code had stopped working only to find that it was because I'd done pip install pydal for something else and foolishly not used a venv. Uninstalled pydal and everything was good again. So warning to others, avoid globally installing pydal

Massimo Di Pierro

unread,
Apr 24, 2018, 6:02:54 PM4/24/18
to web2py-users
strange the local pydal should take precendence over the pip installed one. did you change the order package import somehow?
Reply all
Reply to author
Forward
0 new messages