I don't think that you need to use the dotted notation for the reference.
you just have a table whose pk is "model_id" instead of "id".
Try just 'reference car_model'.
PS: keyed table in web2py are when you need to pass a primarykey=[] to the
table definition.... in your case it's just a matter of column names more
than one of table structure.
On Friday, October 11, 2013 12:25:33 PM UTC+2, James Thompson wrote:
>
> Wondering about support for legacy Mysql tables in web2py. Read the book
> section on legacy databases, but keep getting:
> <type 'exceptions.SyntaxError'> keyed tables can only reference other
> keyed tables (for now)
> My mysql db and web2py models like something like this:
>
> CREATE TABLE `car_models` (
> `model_id` int(10) unsigned NOT NULL auto_increment,
> `model_name` text NOT NULL,
> PRIMARY KEY (`model_id`)
> )
>
> CREATE TABLE `cars` (
> `car_id` int(10) unsigned NOT NULL auto_increment,
> `model_id` int(10) unsigned NOT NULL,
> PRIMARY KEY (`car_id`)
> )
>
> web2py model:
>
> x_db = DAL('mysql://user:password@db/database')
>
> x_db.define_table('car_models',
> Field('model_id','id'),
> Field('model_name','string'),
> migrate=False
> )
>
> x_db.define_table('cars',
> Field('car_id','id'),
> Field('model_id','reference car_models.model_id'),
> Field('note','text'),
> migrate=False
> )
>
>
>
--
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/groups/opt_out.