@Yarko

> - I REALLY like the idea of mapping existing databases so that you can
> interface them with web2py;
> - I REALLY think this mapping belongs in the DB --- NOT in web2py code.

Ideas, suggestions, debate, all good.

> A view is kind of a special SQL select statement - so maybe this THIS could
> be included as part of the DAL... that would actually be the right way to
> let people easily map from web2py (I don't know why I didn't think of that
> before).

This is what I am looking for, those 'AHA' moments.

@Massimo

> What about the syntax:
>
> db.define_view('myview',db.Field('col1'),db.Field('col2'),select=db
> (...)._select(....))

My first idea is more along the lines of:

db.define_view('viewname',sqlset,fields=[],maybe_labels=
[],mapidto=...)

so when you create your view, e.g.:
db.define_view('v1',db.person.id==db.dog.owner,fields=
['person.name','dog.name'],...)
translates in sqlite to
cursor.execute('create view v1 as select person.name, dog.name from
person join dog on person.id = dog.owner')

after which you can:
db.v1.select()
equiv. to
cursor.execute('select * from v1')

> A view would be a special table that does not have an "id" field and
> does not support insert.

No id for non-web2py tables, map to something else.
Why not insert? don't use SQLFORM use VIEWFORM ;-)

(Warning: this ideas are just brainstorming and need to be refined).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to