On Monday, June 6, 2016 at 5:17:34 PM UTC-4, Sammy wrote:
>
> Oh sure, I understand the importance of define.table as a way to create 
> table if it does not exist already. But for existing tables, how is it that 
> an oracle client is able to understand the structure of a table to do 
> queries without further instructions but for DAL you need to explicitly 
> define it?
>

If you want to manually write your own SQL queries (being sure to avoid SQL 
injection) and then get back a standard database driver result set (i.e., a 
list of tuples), then there is no need to use the DAL at all. Just use the 
database driver, make a connection, and do things the way you want.

However, have a look at some of the DAL features: 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer. 
Then there is SQLFORM, SQLTABLE, and SQLFORM.grid, which make use of the 
DAL. If any of those features appeal to you, you might find it worth the 
effort to define DAL models representing your database tables. Without such 
models, the DAL wouldn't know enough about your database schema to enable 
all of that functionality. Futhermore, many attributes of the DAL models go 
beyond merely representing the database schema and provide additional 
information/functionality regarding your data models (e.g., validators, 
representation functions, form and grid labels, computation functions, file 
uploads, etc.).

Also, note that if you are starting with an existing database and need help 
constructing DAL model code based on your current database schema, you can 
use/adapt one of the scripts that come with web2py, such as 
https://github.com/web2py/web2py/blob/master/scripts/extract_oracle_models.py.

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