Will web2py support database view? When?

455 views
Skip to first unread message

heidan

unread,
Aug 26, 2010, 1:05:54 AM8/26/10
to web2py-users
hi,

Is there a way to work with database views using the DAL? I've got a
bunch of views in my database that handle common queries. BUt didn't
see good answers and neither find interface in DAL.

Is there any plan to support database view and when? Anyway accessing
view is performing better than query in controller scripts.

Cheers,
heidan

Vasile Ermicioi

unread,
Aug 26, 2010, 6:50:17 AM8/26/10
to web...@googlegroups.com
if  you can query your views with sql that should be possible with dal too,
just declare your views as web2py tables and set migrate=False (no need to create tables)

something like

db.define_table('your_view_name',
    Field('field1'),
    Field('field2'),
    migrate=False)

Mohamed Zenadi

unread,
Aug 26, 2010, 2:31:50 AM8/26/10
to web...@googlegroups.com
Hey,

I don't know if you can just follow the Django way, in which you simply create a model for your db view. 

Cheers

mdipierro

unread,
Aug 26, 2010, 8:50:15 AM8/26/10
to web2py-users
yes

David Ripplinger

unread,
Apr 18, 2013, 4:19:05 PM4/18/13
to web...@googlegroups.com
I'm not familiar with the Django way. Web2py is my first serious attempt at web programming. What is the Django way, or (alternatively) what is the cleanest way, to use database views in web2py? Should I just do the define_table with migrate=False described by Vasile in this thread, or is there another way I should know about?

Niphlod

unread,
Apr 18, 2013, 4:33:44 PM4/18/13
to web...@googlegroups.com
defining a "fake table" that points to the view and set migrate=False is definitely the best (and recommended) way to do it.
Reply all
Reply to author
Forward
0 new messages