On Tuesday, June 7, 2016 at 11:36:43 AM UTC-4, Sammy wrote:
>
> Thanks for your responses. I certainly want to take advantage of 
> SQLFORM.grid etc. and I don't mind defining tables. However, I am getting 
> errors. 
>
> Initially, I was getting the error previously mentioned, i.e.  <class 
> 'cx_Oracle.DatabaseError'> ORA-00904: "Table1"."ID": invalid identifier. 
> Using the link for legacy DB provided by Anthony, I added key field using 
> Field('....', 'id'), but now I am getting this error: <type 
> 'exceptions.ValueError'> invalid literal for long() with base 10:'..'
>
> What am I doing wrong?
>

In web2py, the "id" field must be an auto-incrementing integer field. If 
this is not the case for your table (and you cannot change it), then you 
must instead use the "primarykey" argument (see 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Legacy-databases-and-keyed-tables),
 
though this entails some limitations.
 

> I have a few questions that might help me in this-
>
> 1) When they say "legacy DB" do they mean all database created outside of 
> web2py?
>

Yes, though a more important distinction is whether the database tables use 
an auto-incrementing integer field as the primary key (and whether this is 
used for all references). See link above.
 

> 2) Do I need to define ALL the fields available in the real Table or can I 
> get away with defining just the fields that I am interested in? 
>

No, just the fields you are using.
 

> 3) Do I need to specify "type" for each field to match real field 
> type? What if there is no one to one mapping available? 
>

Ideally. At least provide a type consistent with the data that will be 
returned by the database driver (e.g., don't tell web2py to expect floats 
from a string field).

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