SQLTABLE columns in 2.21.1

30 views
Skip to first unread message

Dave S

unread,
Dec 20, 2021, 11:18:43 PM12/20/21
to web2py-users
The code in sqlhtml.py for SQLTABLE has changed along the way from 2.18.5 to 2.21.1, especially in the way it handles columns.

This used to work:
in 2.21.1, I get an error

{{=SQLTABLE(rows, truncate=35, headers = {'QuarterMaster.IssueYr':'Year', 'QuarterMaster.StateNm':'State', 'QuarterMaster.Other':'Other', 'QuarterMaster.Mint':'Mint', 'QuarterMaster.NumAdded':'Count'},
    columns=['QuarterMaster.IssueYr', 'QuarterMaster.StateNm', 'QuarterMaster.Other', 'QuarterMaster.Mint', 'QuarterMaster.NumAdded'], _class="table-striped myeheaders")}}

in 2.21.1, I get an error

Traceback (most recent call last):
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\applications\QuarterMaster\views\default/sortedQ.html", line 77, in <module>
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\gluon\sqlhtml.py", line 3544, in __init__
"Column %s not found (SQLTABLE)" % colname)
KeyError: 'Column IssueYr not found (SQLTABLE)'


I've tried "QuarterMaster.IssueYr", "db.QuarterMaster.IssueYr", "IssueYr", and "rows.IssueYr".
Same error.

If I eliminate the columns argument, no error, but my data doesn't show. I've verified in the controller that the data gets into rows, and looks like

<Row {'PostDate': datetime.date(2021, 12, 20), 'IssueYr': 1965L, 'StateNm': None, 'Other': None, 'Mint': 'x', 'id': 3647L, 'NumAdded': 1L}>

What do I need to make this work again?

Dave S
/dps


Dave S

unread,
Jan 3, 2022, 7:48:18 PM1/3/22
to web2py-users
On Monday, December 20, 2021 at 8:18:43 PM UTC-8 Dave S wrote:
The code in sqlhtml.py for SQLTABLE has changed along the way from 2.18.5 to 2.21.1, especially in the way it handles columns.


Well, actually from 2.14.6, as I appeared to not have run this app in 2.18.5.  The problem was not in SQLTABLE, it was in what I'm trying to return.  
I initialized rowed as follows:

    rowed = Rows(db)
    rowed.records = []
 

    and then I chew through some stuff to add rowed.record[0...n]

    return dict(rowed = rowed, ...)

stopped working by 2.18.5, according to beautify(response._vars).  Eventually I figured out I needed to copy rows.fields and rows.colnames to rowed.

/dps



 
Reply all
Reply to author
Forward
0 new messages