What is the need for you to create a primary key in a field name or char?
look this:
It defines, stores and returns a Table object called "person" containing a
field (column) "name". This object can also be accessed via db.person, so
you do not need to catch the return value.
id: Notes about the primary key

Do not declare a field called "id", because one is created by web2py
anyway. Every table has a field called "id" by default. It is an
auto-increment integer field (starting at 1) used for cross-reference and
for making every record unique, so "id" is a primary key. (Note: the id
counter starting at 1 is back-end specific. For example, this does not
apply to the Google App Engine NoSQL.)

Optionally you can define a Field of type='id' and web2py will use this
field as auto-increment id field. This is not recommended except when
accessing legacy database tables which have a primary key under a different
name. With some limitation, you can also use different primary keys using
the primarykey parameter. primarykey is explained shortly below.
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#id--Notes-about-the-primary-key

a good practice of development is not creating primary keys are named,
another element would be important to social security + name ,for example.

Hope this helps.




                   [image: http://itjp.net.br] <http://itjp.net.br>
                     http://itjp.net.b <http://itjp.net.br>r
          *Ovidio Marinho Falcao Neto*
                 [email protected]
                            Brasil


2018-01-24 19:54 GMT-03:00 'DenesL' via web2py-users <
[email protected]>:

> Testing web2py 2.16.01 installed from source on Windows 8 with Python
> 2.7.14
>
> I have two tables on MS SQL Server 2012, one is legacy, the other not:
>
> w2p.define_table('person',
>   Field('name', 'string', length=100, notnull=True),
>   Field('info', 'string', length=100),
>   primarykey=['name']
> )
>
> w2p.define_table('persona',
>   Field('name', 'string', length=100, notnull=True),
>   Field('info', 'string', length=100)
> )
>
> The appadmin shows the records for both tables but the legacy anchors to
> display each record are being incorrectly generated as:
>
> <a href="<function <lambda> at 0x00000000071AAEB8>/person?name=Ana">Ana
> </a>
>
> http://10.0.0.27:8000/test/appadmin/select/%3Cfunction%
> 20%3Clambda%3E%20at%200x00000000071AAEB8%3E/person?name=Ana
>
> Regards,
> Denes
>
> --
> 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.
>

-- 
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