Hello everyone. I am trying to build an application to annotate some data, and I am struggling with the data model. Here is what I have written so far:
# coding: utf8 iliad = SQLDB(REMOVED) ann = SQLDB(REMOVED) iliad.define_table('forum', SQLField('name', type = 'string' , length = 32 ), SQLField('url', type = 'longtext' ), migrate = False) iliad.define_table('post', SQLField('thread_id', type = 'integer' , length = 11 ), SQLField('position', type = 'integer' , length = 11 ), SQLField('text', type = 'longtext' ), SQLField('author', type = 'string' , length = 32 ), SQLField('timestamp', type = 'string' , length = 32 ), migrate = False) iliad.define_table('thread', SQLField('forum_id', type = 'integer' , length = 11 ), SQLField('url', type = 'longtext' ), SQLField('html', type = 'longtext' ), SQLField('title', type = 'longtext' ), SQLField('summary', type = 'longtext' ), SQLField('posts', type = 'longtext' ), SQLField('updated_at', type = 'datetime' ), SQLField('created_at', type = 'datetime' ), migrate = False) ann.define_table( 'target' , SQLField('username','string') , SQLField('thread', iliad.thread) , SQLField('thread_len', 'integer') ) ann.target.username.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB (iliad,'iliad.username')] ann.define_table( 'user_qualities' , SQLField('iliadotator') , SQLField('target',ann.target) , SQLField('clarity','integer') , SQLField('enthusiasm','integer') , SQLField('proficiency','integer') ) ann.user_qualities.username.requires=[IS_NOT_EMPTY(),IS_IN_DB (iliad,'iliad.id','iliad.username')] Please note I have removed the DB location details for security reasons. However, both are MySQL databases, running on the same server. As you can see, the first three tables refer to data that already exists in a database. The later tables need to reference the former tables. I am thinking of storing the annotations in a separate table from the original data, but I what I have written above is rejected with the following traceback: Traceback (most recent call last): File "/home/mlui/web2py/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/home/mlui/web2py/applications/user_annotation/models/db.py", line 33, in <module> , SQLField('thread_len', 'integer') File "/home/mlui/web2py/gluon/sql.py", line 1004, in define_table t._create_references() File "/home/mlui/web2py/gluon/sql.py", line 1207, in _create_references raise SyntaxError, 'SQLTable: table \'%s\'does not exist' % referenced SyntaxError: SQLTable: table 'thread'does not exist Maybe I am making a simple beginner mistake? Thank you for your time. Cheers Marco --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---