I still not understand the answer. How could I build primary key on two fields by default sqlite? Or, is there any better method to build 'unique key' on multiple fields?
On 5月20日, 上午12時30分, drayco <antrod...@gmail.com> wrote: > Thank's a lot Nico de Groot. > > It worked for me too even with mysql. > > On 18 mayo, 07:24, Nico de Groot <ndegr...@chello.nl> wrote: > > > > > Hi Denes, > > > I got the same syntax error (SyntaxError: invalid table "account" > > attribute: sequence_name ) when using a legacy database (by specifying > > the primarykey in 'define_table'). I tracked it down to the init > > method of KeyedTable in sql.py and made an adjustment that worked - > > for me at least - see below. > > > Nico de Groot > > > class KeyedTable(Table): > > ... > > def __init__( > > self, > > db, > > tablename, > > *fields, > > **args > > ): > > ... > > self._trigger_name = args.get('trigger_name', None) > > self._sequence_name = args.get('sequence_name', None) > > > for k,v in args.iteritems(): > > #patch NCdG > > if k in ['trigger_name','sequence_name']: > > continue > > #/patch NCdG > > if k != 'primarykey': > > > ... > > > On 9 mei, 18:57, DenesL <denes1...@yahoo.ca> wrote:> On May 9, 9:08 am, > > Iceberg <iceb...@21cn.com> wrote: > > > > > Thanks for the info. Would you please comment on my following > > > > understanding and further questions? > > > > > 1. Keyed tables are only designed for dealing with legacy tables. Is > > > > that true? And how do we definemultipleprimary keys in a brand new > > > > db? Consider the address book scenario in my previous post. > > > > Keyed tables support is primarily for legacy tables that do not have a > > > field that can be used as id field. It can also be used in newly > > > created tables since all operations work (except update_record). Note > > > that references are specified as tablename.fieldname and can only > > > reference other keyed tables. > > > > > 2. Keyed tables are yet to be supported in some other DB engines, but > > > > NOT the handy SQLite. Is there any special reason for that? AFAIK > > > > SQLite contains native support formultipleprimary key. > > > > I might be wrong but I think SQLite does not have FK (field level > > > foreign key) and TFK (table level foreign key) required for the keyed > > > table support in web2py. > > > > > 3. Neither keyword KeyedTable nor primarykey can be found > > > > inhttp://www.web2py.com/bookrightnow. Why? Denes' good work deserves > > > > being mentioned as a dedicated section. > > > > It was added after the book was made available and it would be my > > > fault, I either had no time or forgot about it. > > > > > Thanks in advance. > > > > > Sincerely, > > > > Iceberg- Tekst uit oorspronkelijk bericht niet weergeven - > > > > - Tekst uit oorspronkelijk bericht weergeven -