Is it possible to show the results from a SELECT (made with SQLite using db.executesql) in a grid?

51 views
Skip to first unread message

João Matos

unread,
Apr 1, 2019, 6:17:52 PM4/1/19
to web2py-users
Hello,

Is it possible to show the results from a SELECT (made with SQLite using db.executesql) in a grid?
I have this

    result = db.executesql(
           
"SELECT auth_user.id, auth_user.username, "
           
"auth_user.canceled_on, "
           
"auth_user.canceled_by, "
           
"SUM(auth_group.role = 'Operador') operador, "
           
"SUM(auth_group.role = 'Verificador') verificador, "
           
"SUM(auth_group.role = 'Supervisor') supervisor "
           
"FROM auth_user "
           
"LEFT JOIN auth_membership ON auth_user.id = auth_membership.user_id "
           
"LEFT JOIN auth_group ON auth_group.id = auth_membership.group_id "
           
"GROUP BY username ORDER BY username"
   
)

that returns a list of tuples, and would like to show it using the grid.

Is it possible?

Thanks,

JM

Val K

unread,
Apr 2, 2019, 1:43:41 AM4/2/19
to web2py-users
Create view in sqlite "CREATE VIEW your_tbl_name AS SELECT ..." using executesql and define corresponding web2py table with migrate=False, fake_migrate=True

João Matos

unread,
Apr 2, 2019, 4:55:30 AM4/2/19
to web2py-users
That worked. Thanks.

Anthony

unread,
Apr 2, 2019, 11:52:45 AM4/2/19
to web2py-users
Note, you do not need to set fake_migrate, as long as migrate=False (the DAL will simply ignore migrations for that table).

João Matos

unread,
Apr 2, 2019, 7:36:53 PM4/2/19
to web2py-users
Thanks for the tip Anthony.
Is the purpose of the fake_migrate parameter only for the scenarios in the manual or are there any other uses for it?
Reply all
Reply to author
Forward
0 new messages