On Friday, October 28, 2016 at 5:22:29 AM UTC-4, Arun Kumar wrote:
>
> Hi,
>     I'm new to web2py and trying to develop an application. I have some 
> queries on how to do certain things on web2py best way,
>
> 1. I have few tables in my application. Should I write definition in a 
> single file inside models (models/db.py) or each table definition in a 
> separate file?
>

If you need all tables on every request, it should be a bit more efficient 
to have the definitions in a single file (to minimize the number of files 
that must be read on each request). But if you only need particular tables 
for particular requests, it can be more efficient to (a) use separate model 
files executed conditionally only when needed (see docs for how to do 
that), or (b) move table definitions to modules and import in controllers 
where needed. It is also a good idea to enable lazy table definitions.
 

> 2. Can we write DB queries in controller itself or it can be separated 
> from controller? If it can be maintained in separated files what is the 
> best place to keep and how to access it inside controllers?
>

It's just Python, so you can do whatever you want. You can always put code 
in modules and import where needed.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to