On Jun 15, 7:13 am, Jose <[email protected]> wrote:
> On 15 jun, 05:12, Sky <[email protected]> wrote:
>
> > Thank you Jose,
> > but I couldn't find out if you used define_table or not?
> > can you drop me a piece of your code?
> > i get 'invalid query' error when i query on my views.
>
> They are declared in the same way that a real table. Then you can
> create queries, use them to link to other tables, etc.

So you create a view in your db (not in web2py), and it sounds like
Jose included a field called "id".

On the web2py end, you would create a define_table definition, with
"migrate=False", which will prevent generation of any SQL to modify
the table - you would just match your define_table fields with what
you know you created in your view (note:  a table definition in web2py
does NOT need to specify an "entire" SQL table as it exists on the db
- only the fields that your web2py app will be accessing - so you can
make test connections very quickly, simply).

>
> In my specific case, no insert or update records, but if your database
> engine accepts, there would be drawbacks.

Performance of views can vary - so if you're doing any serious work,
you should pay attention to performance effects of views on your
particular server.


> One more thing, the view does not necessarily have to contain fields
> for a single table, but can have as many joins as you like, that use
> is transparent.
>
> Jose

Reply via email to